{ "info": { "author": "John H Williamson", "author_email": "johnhw@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# pfilter\nBasic Python particle filter. Written to be simple and clear; not necessarily most efficient or most flexible implementation. Depends on [NumPy](http://numpy.org) only. \n\n## Installation\n\nAvailable via PyPI:\n\n pip install pfilter\n \nOr install the git version:\n\n pip install git+https://github.com/johnhw/pfilter.git\n\n## Usage\nCreate a `ParticleFilter` object, then call `update(observation)` with an observation array to update the state of the particle filter.\n\nYou need to specify at the minimum:\n* an **observation function** `observe_fn(state) => observation matrix` which will return a predicted observation for an internal state.\n* a function that samples from an **initial distributions** `prior_fn=>(n,d) state matrix` for all of the internal state variables. These are usually distributions from `scipy.stats`. The utility function `independent_sample` makes it easy to concatenate sampling functions to sample the whole state vector.\n* a **weight function** `weight_fn(real_observed, hyp_observed_array) => weight vector` which specifies how well each of the `hyp_observed` arrays match the real observation `real_observed`. This must produce a strictly positive weight value, where larger means more similar.\n\nTypically, you would also specify:\n* a `dynamics_fn` to update the state based on internal (prediction) dynamics, and a \n* `noise_fn` to add diffusion into the sampling process. \n\nFor example, assuming there is a function `blob` which draws a blob on an image of some size (the same size as the observation):\n\n```python\n from pfilter import ParticleFilter, gaussian_noise, squared_error, independent_sample\n columns = [\"x\", \"y\", \"radius\", \"dx\", \"dy\"]\n from scipy.stats import norm, gamma, uniform \n \n # prior sampling function for each variable\n # (assumes x and y are coordinates in the range 0-32) \n prior_fn = independent_sample([uniform(loc=0, scale=32).rvs, \n uniform(loc=0, scale=32).rvs, \n gamma(a=2,loc=0,scale=10).rvs,\n norm(loc=0, scale=0.5).rvs,\n norm(loc=0, scale=0.5).rvs])\n \n # very simple linear dynamics: x += dx\n def velocity(x):\n xp = np.array(x)\n xp[0:2] += xp[3:5] \n return xp\n \n # create the filter\n pf = pfilter.ParticleFilter(\n prior_fn=prior_fn, \n observe_fn=blob,\n n_particles=200,\n dynamics_fn=velocity,\n noise_fn=lambda x: \n gaussian_noise(x, sigmas=[0.2, 0.2, 0.1, 0.05, 0.05]),\n weight_fn=lambda x,y:squared_error(x, y, sigma=2),\n resample_proportion=0.1,\n column_names = columns)\n \n # assuming image of the same dimensions/type as blob will produce\n pf.update(image) \n ```\n\nSee the notebook [examples/test_filter.py](examples/test_filter.py) for a working example using `skimage` and `OpenCV` which tracks a moving white circle.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/johnhw/pfilter/tarball/0.2", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/johnhw/pfilter", "keywords": "particle,probabilistic,stochastic,filter,filtering", "license": "", "maintainer": "", "maintainer_email": "", "name": "pfilter", "package_url": "https://pypi.org/project/pfilter/", "platform": "", "project_url": "https://pypi.org/project/pfilter/", "project_urls": { "Download": "https://github.com/johnhw/pfilter/tarball/0.2", "Homepage": "https://github.com/johnhw/pfilter" }, "release_url": "https://pypi.org/project/pfilter/0.2.2/", "requires_dist": null, "requires_python": "", "summary": "A basic particle filter", "version": "0.2.2" }, "last_serial": 4820233, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "86448a680915e87c232877b8942f520a", "sha256": "1180512e67f48e1cd012bc0bbd9b2f00de86b647473f6f4a064d2cc2a6a75480" }, "downloads": -1, "filename": "pfilter-0.1.zip", "has_sig": false, "md5_digest": "86448a680915e87c232877b8942f520a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4946, "upload_time": "2017-02-02T16:05:00", "url": "https://files.pythonhosted.org/packages/56/8c/932f1203c876e2a596c646605de267bbffa27f45f524c3754f22d7ebca7e/pfilter-0.1.zip" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "58457b062b7b50c884d18fec0136b523", "sha256": "b48d0f1fe14331a2c41f42006e6dc0da7a2503b4d64a5f481504cd095f066982" }, "downloads": -1, "filename": "pfilter-0.2.tar.gz", "has_sig": false, "md5_digest": "58457b062b7b50c884d18fec0136b523", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4994, "upload_time": "2019-02-14T12:37:24", "url": "https://files.pythonhosted.org/packages/cf/d5/c94e57bb840f65150530adca15e5848de27d63411a29689fe06db5d1783b/pfilter-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "410a587613870d81b2c30d98de6a012b", "sha256": "5eb1c75a64d7eede48e7aff5268a1827145de1bdf5fe679a4ed240ab9fc6b887" }, "downloads": -1, "filename": "pfilter-0.2.1.zip", "has_sig": false, "md5_digest": "410a587613870d81b2c30d98de6a012b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6690, "upload_time": "2019-02-14T12:47:31", "url": "https://files.pythonhosted.org/packages/71/66/7c9705021f6fb28e275cbfc2e78559d6c8f6c45d839506d48b4d05500fad/pfilter-0.2.1.zip" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "fc5f0b327be64dee91960bdf207cf3f7", "sha256": "c2b549a240dc0d60048e1d9772a240d4bade53dc0701c4f2f5e9336eb7e0fc67" }, "downloads": -1, "filename": "pfilter-0.2.2.zip", "has_sig": false, "md5_digest": "fc5f0b327be64dee91960bdf207cf3f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9438, "upload_time": "2019-02-14T12:49:37", "url": "https://files.pythonhosted.org/packages/24/4d/b4bbae9105ca1da701564b6f75f8b5ddc00d05c77923277a5ff38b2ce537/pfilter-0.2.2.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fc5f0b327be64dee91960bdf207cf3f7", "sha256": "c2b549a240dc0d60048e1d9772a240d4bade53dc0701c4f2f5e9336eb7e0fc67" }, "downloads": -1, "filename": "pfilter-0.2.2.zip", "has_sig": false, "md5_digest": "fc5f0b327be64dee91960bdf207cf3f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9438, "upload_time": "2019-02-14T12:49:37", "url": "https://files.pythonhosted.org/packages/24/4d/b4bbae9105ca1da701564b6f75f8b5ddc00d05c77923277a5ff38b2ce537/pfilter-0.2.2.zip" } ] }