{ "info": { "author": "Oliver K. Ernst", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "# Sample pairs of particles according to a discrete Gaussian\nPython code to sample pairs of a given set of particles in n dims, where the probability for each pair is Gaussian\n\n\n\n## Requirements\n\nPython 3 & Numpy.\n\n## Installation and usage\n\nUse `pip`:\n```\npip install samplePairsGaussian\n```\nor manually:\n```\npython setup.py install\n```\nand in your code:\n```\nfrom samplePairsGaussian import *\n```\nSee also the [examples](examples) folder.\n\n## Idea\n\nGiven a set of `n` particles with positions in `d`-dimensional space denoted by `x_i` for `i=0,1,...,n`.\n\nWe want to sample a pair of particles `i,j` where `i =/= j`, where the probability for sampling this pair is given by:\n```\np(i,j) ~ exp( - |x_i - x_j|^2 / 2 sigma^2 )\n```\nwhere we use `|x|` to denote the `L_2` norm, and `sigma` is some chosen standard deviation.\n\nThis problem is easy to write down, but difficult to implement for large numbers of particles since it requires computing `N^2` distances.\n\nA further problem is that we may want to:\n 1. Add a particle.\n 2. Remove a particle.\n 3. Move a particle.\n\nIn this case, not all distances are affected - these operations should be of order `N`. However, if we sample the discrete distribution by forming the CDF, we will need to recalculate it, which is expensive. Alternatively, if we use rejection sampling, we must have a good candidate (envelope) distribution such that the acceptance ratio is high.\n\nThis library attempts to come up with the most efficient way to perform these operations in Python.\n\nA key way this library reduces computational cost is by introducing a cutoff for particle distances, where pairs of particles separated by a distance greater than the cutoff are not considered for sampling. It is natural to let this be some chosen multiple of the std. dev., i.e. `m*sigma` for some `m`. If we use rejection sampling where candidates are drawn from a uniform distribution, the acceptance ratio should be approximately `( sqrt(2 * pi) * sigma ) / ( 2 * m * sigma ) = 1.253 / m`. (in the first equation: the area of the Gaussian is `1`, divided by the area of the uniform distribution of width `2 * m * sigma` and height `1 / (sqrt(2 * pi) * sigma )`).\n\nIn general, we avoid all use of for loops, and rely extensively on array operations using numpy.\n\n### Multiple species\n\nMultiple species are also supported, where we have multiple species but want to draw two particles of the **same species** (two particles of any species can be done by simply ignoring the species labels).\n\nSpecifically, the classes `ProbCalculatorMultiSpecies` and `SamplerMultiSpecies` implement this.\n\n## Examples\n\nSee the [examples](examples) folder.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/smrfeld/sample-pairs-gaussian", "keywords": "", "license": "GNU General Public License v3.0", "maintainer": "", "maintainer_email": "", "name": "SamplePairsGaussian", "package_url": "https://pypi.org/project/SamplePairsGaussian/", "platform": "", "project_url": "https://pypi.org/project/SamplePairsGaussian/", "project_urls": { "Homepage": "https://github.com/smrfeld/sample-pairs-gaussian" }, "release_url": "https://pypi.org/project/SamplePairsGaussian/1.1/", "requires_dist": null, "requires_python": "", "summary": "Sample pairs of particles according to a discrete Gaussian distrbution", "version": "1.1" }, "last_serial": 5483908, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "410977af6a9ae8dd2c9464ee2f4a1034", "sha256": "cc56578c770c26d21ff8dbe1536a747b812ead4ebd71e61576b39102980c5268" }, "downloads": -1, "filename": "SamplePairsGaussian-1.0-py3.7.egg", "has_sig": false, "md5_digest": "410977af6a9ae8dd2c9464ee2f4a1034", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 34428, "upload_time": "2019-07-03T22:45:58", "url": "https://files.pythonhosted.org/packages/11/be/ec570e809623f5a362d09565dc7009513188c53bf644584ae83f26e7ea51/SamplePairsGaussian-1.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "9db583605f4535039789ed8be4eac257", "sha256": "c7cf60565dca2a3ea7794b04ed0a60e80e84a1557de129793b1f1ba199c06e01" }, "downloads": -1, "filename": "SamplePairsGaussian-1.0.tar.gz", "has_sig": false, "md5_digest": "9db583605f4535039789ed8be4eac257", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9957, "upload_time": "2019-06-20T21:25:33", "url": "https://files.pythonhosted.org/packages/fc/5e/60d5dad65579ba93f65c05a57d4d2e1d4b7453ef67340ebddafb803060be/SamplePairsGaussian-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "d0153a9fbc8a0e3200a9c4cb19440569", "sha256": "d825c4569fb9b0d0d3a1a3248ad6f05b3c6515b72f6a26900582868b9e928720" }, "downloads": -1, "filename": "SamplePairsGaussian-1.1-py3.7.egg", "has_sig": false, "md5_digest": "d0153a9fbc8a0e3200a9c4cb19440569", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 45761, "upload_time": "2019-07-03T22:45:59", "url": "https://files.pythonhosted.org/packages/50/85/c6bdff06b238f1931cc56d2e6d07435e2022443f43438054f219d951475f/SamplePairsGaussian-1.1-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "d5757327420e9a7b4fd8973b1814275e", "sha256": "669440f2a15dc5c2f7b7abb95a12c01b86fbb045f4636cbcc3c749b4799b78b8" }, "downloads": -1, "filename": "SamplePairsGaussian-1.1.tar.gz", "has_sig": false, "md5_digest": "d5757327420e9a7b4fd8973b1814275e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12058, "upload_time": "2019-07-03T22:46:01", "url": "https://files.pythonhosted.org/packages/e1/bb/1c60747ad4d15c39793ad2f09e1d79e85c242c605bc6873d340fa67e87e4/SamplePairsGaussian-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d0153a9fbc8a0e3200a9c4cb19440569", "sha256": "d825c4569fb9b0d0d3a1a3248ad6f05b3c6515b72f6a26900582868b9e928720" }, "downloads": -1, "filename": "SamplePairsGaussian-1.1-py3.7.egg", "has_sig": false, "md5_digest": "d0153a9fbc8a0e3200a9c4cb19440569", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 45761, "upload_time": "2019-07-03T22:45:59", "url": "https://files.pythonhosted.org/packages/50/85/c6bdff06b238f1931cc56d2e6d07435e2022443f43438054f219d951475f/SamplePairsGaussian-1.1-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "d5757327420e9a7b4fd8973b1814275e", "sha256": "669440f2a15dc5c2f7b7abb95a12c01b86fbb045f4636cbcc3c749b4799b78b8" }, "downloads": -1, "filename": "SamplePairsGaussian-1.1.tar.gz", "has_sig": false, "md5_digest": "d5757327420e9a7b4fd8973b1814275e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12058, "upload_time": "2019-07-03T22:46:01", "url": "https://files.pythonhosted.org/packages/e1/bb/1c60747ad4d15c39793ad2f09e1d79e85c242c605bc6873d340fa67e87e4/SamplePairsGaussian-1.1.tar.gz" } ] }