{ "info": { "author": "John Kleint", "author_email": "mediantracker-general@lists.sourceforge.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "Track the median of a stream of values \"on-line\" in reasonably efficient \nfashion.\n\nUsage::\n\n from mediantracker import MedianTracker\n tracker = MedianTracker()\n tracker.add(1)\n tracker.add(2)\n tracker.add(3)\n tracker.add(4)\n assert tracker.lower_median() == 2\n assert tracker.upper_median() == 3\n \n``MedianTracker`` supports efficient median queries on and dynamic\nadditions to a list of values. It provides both the lower and upper median\nof all values seen so far. Any ``__cmp__()``-able object can be tracked,\nin addition to numeric types. ``add()`` takes *log(n)* time for a tracker\nwith *n* items; ``lower_median()`` and ``upper_median()`` run in constant\ntime. Since all values must be stored, memory usage is proportional to the\nnumber of values added (*O(n)*).\n\nThe values can be accessed via iteration over the ``MedianTracker``,\nthough they are not ordered in any particular way::\n\n sum = 0.0\n for val in tracker:\n sum += val\n mean = sum / len(tracker) \n\nUse this module if you are processing values \"on-line,\" one at a time, as\nthey arrive, and need to know the new median after each new value (or\nbatch of values). If you just want the median of a whole list, there are\nmuch more efficient linear-time median (or more general k-th smallest\nselection) algorithms. Using this module will take *O(nlogn)* time and an\nextra *O(n)* space to compute the median of *n* items. On the other hand,\na ``MedianTracker`` will only take *O(nlogn + m)* time for any sequence of\n*n* adds and *m* median queries, whereas running a traditional\nnon-incremental median algorithm *m* times would take *O(n*m)*.\n\nFinally, some sources define the median of an even-length list to be the\naverage of the middle two values. This is easily and efficiently computed\n(in constant time)::\n\n tracker = MedianTracker([1, 2, 3, 4])\n median = (tracker.lower_median() + tracker.upper_median()) / 2.0\n assert median == 2.5", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://sourceforge.net/projects/mediantracker/", "keywords": "median statistics online incremental dynamic mathematics", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "mediantracker", "package_url": "https://pypi.org/project/mediantracker/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mediantracker/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://sourceforge.net/projects/mediantracker/" }, "release_url": "https://pypi.org/project/mediantracker/1.0/", "requires_dist": null, "requires_python": null, "summary": "Tracks the overall median of a stream of values \"on-line\" in reasonably efficient fashion.", "version": "1.0" }, "last_serial": 794633, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "77666357b7340811a8b4d995c9ce1135", "sha256": "c94504b2e82354e7f1241bfb521c88681beef159a8e95af0145262f77f5beacd" }, "downloads": -1, "filename": "mediantracker-1.0.tar.gz", "has_sig": false, "md5_digest": "77666357b7340811a8b4d995c9ce1135", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6409, "upload_time": "2009-09-02T22:27:12", "url": "https://files.pythonhosted.org/packages/44/94/d67a68b8adb5c16ade6ff2a3054ef1c4a48f0197015cf08630b75d6d4ae5/mediantracker-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "77666357b7340811a8b4d995c9ce1135", "sha256": "c94504b2e82354e7f1241bfb521c88681beef159a8e95af0145262f77f5beacd" }, "downloads": -1, "filename": "mediantracker-1.0.tar.gz", "has_sig": false, "md5_digest": "77666357b7340811a8b4d995c9ce1135", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6409, "upload_time": "2009-09-02T22:27:12", "url": "https://files.pythonhosted.org/packages/44/94/d67a68b8adb5c16ade6ff2a3054ef1c4a48f0197015cf08630b75d6d4ae5/mediantracker-1.0.tar.gz" } ] }