{ "info": { "author": "Tim McNamara", "author_email": "paperless@timmcnamara.co.nz", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "The ``PDist`` is designed to make it easy to make it easy to make \r\nthings happen in a probablistic manner. Provide keys with an \r\nassociated probability attached, and then call the resulting\r\nobject when you need a new value.\r\n\r\n >>> mood = PDist({'happy': 0.3, 'neutral': 0.6, 'sad': 0.1})\r\n >>> mood()\r\n 'happy'\r\n >>> mood()\r\n 'neutral'\r\n\r\nYou can retrieve the distribution of how those values are applied\r\nby accessing the ``PDist.distribution`` attribute:\r\n\r\n >>> mood.distribution\r\n [('happy', 0.3), ('neutral', 0.6), ('sad', 0.1)]\r\n\r\nAs well as providing a dict to assign probabilities, you can\r\nsend in a list of lists/tuples. This allows for for non-hashable\r\ntypes to be used. This means that you provide objects such as \r\nfunctions to be used as keys:\r\n\r\n >>> def grumpy(news):\r\n ... return ':/'\r\n >>> def happy(news):\r\n ... return ':)'\r\n >>> react = PDist([(grumpy, 0.7), (happy, 0.3)])\r\n >>> reaction = react()\r\n >>> reaction(\"We're getting married!\")\r\n ':/'\r\n\r\nYou are not restricted to adding your input variables up to 1. For\r\nexample, if you only have a tally chart, and wish to calculate a probability distribution from that sample, you can provide that too:\r\n\r\n >>> spotted = {'geese': 0, 'ducks': 12, 'sparrows': 4, 'other': 39}\r\n >>> bird_pdist = PDist(spotted)\r\n >>> bird_pdist.distribution\r\n [('geese', 0.0), ('sparrows', 0.07272727272727272), ('ducks', 0.21818181818181817), ('other', 0.7090909090909091)]\r\n\r\nRetrieving the probability of a particular key is supported. However,\r\nthe search strategy is very inefficient and probably shouldn't be used\r\noutside of the interactive Python shell.\r\n\r\n >>> bird_pdist['geese']\r\n 0.0", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/timClicks/choices/zipball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/timClicks/choices", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "choices", "package_url": "https://pypi.org/project/choices/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/choices/", "project_urls": { "Download": "https://github.com/timClicks/choices/zipball/master", "Homepage": "https://github.com/timClicks/choices" }, "release_url": "https://pypi.org/project/choices/0.1/", "requires_dist": null, "requires_python": null, "summary": "Making choices from a probability distribution", "version": "0.1" }, "last_serial": 787381, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ffe50023f36f032d9abf769f9a93453c", "sha256": "ae673699f949b8e095c59a0a131b12abc59d409f22e2fb88de6bb15aab01fe7e" }, "downloads": -1, "filename": "choices-0.1.tar.gz", "has_sig": false, "md5_digest": "ffe50023f36f032d9abf769f9a93453c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2507, "upload_time": "2012-02-25T04:04:59", "url": "https://files.pythonhosted.org/packages/21/49/1ed382aec6fb4854fdd33e45489a190ffcbd056ca2a494a7aead85edced7/choices-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ffe50023f36f032d9abf769f9a93453c", "sha256": "ae673699f949b8e095c59a0a131b12abc59d409f22e2fb88de6bb15aab01fe7e" }, "downloads": -1, "filename": "choices-0.1.tar.gz", "has_sig": false, "md5_digest": "ffe50023f36f032d9abf769f9a93453c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2507, "upload_time": "2012-02-25T04:04:59", "url": "https://files.pythonhosted.org/packages/21/49/1ed382aec6fb4854fdd33e45489a190ffcbd056ca2a494a7aead85edced7/choices-0.1.tar.gz" } ] }