{ "info": { "author": "Katherine Crowson", "author_email": "crowsonkb@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "average\n=======\n\nMoving averaging schemes (exponentially weighted, polynomial-decay). Running averages only are maintained; no history of values is stored.\n\nUsage (EWMA; exponentially weighted moving average)\n---------------------------------------------------\n\n.. code:: python\n\n from average import EWMA\n\n # Create a scalar running average.\n # beta=0.5 is the smoothing factor.\n avg = EWMA(beta=0.5)\n avg.update(1)\n avg.update(2)\n print(avg.get()) # Prints 1.6666666666666667.\n\nThe average is weighted toward the most recent value. That is, its value is ``1 * 1/3 + 2 * 2/3``. The default value for ``beta`` is 0.9, which is reasonable for many uses. Higher smoothing values increase the amount of weight put on less recent values in the average.\n\nYou can also create running averages shaped like NumPy arrays by supplying a shape and dtype (defaults to ``numpy.float64``). For example:\n\n.. code:: python\n\n avg = EWMA((4, 4), np.float64)\n # or, equivalently:\n avg = EWMA.like(np.eye(4))\n avg.update(np.eye(4))\n print(avg.get()) # Prints a 4x4 identity matrix.\n\nFor example, you could use ``EWMA`` to maintain a running average of HxWx3 video frames, if the frames are in NumPy array format or convertible to it.\n\nUsage (PDMA; polynomial-decay moving average)\n---------------------------------------------\n\nWith the polynomial decay parameter ``eta`` set to the default value of 0, ``PDMA`` acts as a simple average (averages equally over all previous values). A history of values is not kept.\n\n.. code:: python\n\n from average import PDMA\n\n avg = PDMA()\n avg.update(1)\n avg.update(2)\n avg.update(3)\n print(avg.get()) # Prints 2.0.\n\nHigher values of ``eta`` correspond to a polynomially decaying window of degree ``eta`` stretching back over all previous values. The higher ``eta`` is set, the more weight is placed on more recent values.\n\n.. code:: python\n\n avg = PDMA(eta=1)\n for i in range(1, 5):\n avg.update(i)\n print(avg.get()) # Prints 3.0.\n\nIn our example, setting ``eta`` to 0 would instead have printed the simple average 2.5. ``eta`` can be set arbitrarily high, but 0, 1, and 3 are probably reasonable values for many uses. Similarly to ``EWMA``, ``PDMA`` running averages can be shaped like NumPy arrays and have a NumPy data type (not shown).\n\nReferences\n----------\n\nThe formula for an exponentially weighted average with initialization bias correction is given in \"`Adam: A Method for Stochastic Optimization `_\" by Kingma and Ba.\n\nThe formula for polynomial-decay averaging is given in section 4 of \"`Stochastic Gradient Descent for Non-smooth Optimization: Convergence Results and Optimal Averaging Schemes `_\" by Shamir and Zhang.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/crowsonkb/average", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "average", "package_url": "https://pypi.org/project/average/", "platform": "", "project_url": "https://pypi.org/project/average/", "project_urls": { "Homepage": "https://github.com/crowsonkb/average" }, "release_url": "https://pypi.org/project/average/1.0/", "requires_dist": null, "requires_python": "", "summary": "Moving averaging schemes (exponentially weighted, polynomial-decay).", "version": "1.0" }, "last_serial": 4326428, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "876746e8925580cc4e4c8f531fb41395", "sha256": "f55b735243069e8b7f7b1470a2820ec72278b7b14e36a6ecea1baf4b502fd2a0" }, "downloads": -1, "filename": "average-1.0.tar.gz", "has_sig": false, "md5_digest": "876746e8925580cc4e4c8f531fb41395", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3788, "upload_time": "2018-10-01T01:26:01", "url": "https://files.pythonhosted.org/packages/2a/56/dcfc4f5ca7a933df8a20a1daa441a16658ab456582d8286ba53d43b7557d/average-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "876746e8925580cc4e4c8f531fb41395", "sha256": "f55b735243069e8b7f7b1470a2820ec72278b7b14e36a6ecea1baf4b502fd2a0" }, "downloads": -1, "filename": "average-1.0.tar.gz", "has_sig": false, "md5_digest": "876746e8925580cc4e4c8f531fb41395", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3788, "upload_time": "2018-10-01T01:26:01", "url": "https://files.pythonhosted.org/packages/2a/56/dcfc4f5ca7a933df8a20a1daa441a16658ab456582d8286ba53d43b7557d/average-1.0.tar.gz" } ] }