stats-arrays


Namestats-arrays JSON
Version 0.7 PyPI version JSON
download
home_pageNone
SummaryStandard NumPy array interface for defining uncertain parameters
upload_time2024-08-19 16:46:49
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            The `stats_arrays` package provides a standard NumPy array interface for defining uncertain parameters used in models, and classes for Monte Carlo sampling. It also plays well with others.

# Motivation

* Want a consistent interface to SciPy and NumPy statistical function
* Want to be able to quickly load and save many parameter uncertainty distribution definitions in a portable format
* Want to manipulate and switch parameter uncertainty distributions and variables
* Want simple Monte Carlo random number generators that return a vector of parameter values to be fed into uncertainty or sensitivity analysis
* Want something simple, extensible, documented and tested

The `stats_arrays package was originally developed for the [Brightway2 life cycle assessment framework](https://docs.brightway.dev/), but can be applied to any stochastic model.

# Example

```python

>>> from stats_arrays import *
>>> my_variables = UncertaintyBase.from_dicts(
...     {'loc': 2, 'scale': 0.5, 'uncertainty_type': NormalUncertainty.id},
...     {'loc': 1.5, 'minimum': 0, 'maximum': 10, 'uncertainty_type': TriangularUncertainty.id}
... )
>>> my_variables
array([(2.0, 0.5, nan, nan, nan, False, 3),
       (1.5, nan, nan, 0.0, 10.0, False, 5)],
    dtype=[('loc', '<f8'), ('scale', '<f8'), ('shape', '<f8'),
           ('minimum', '<f8'), ('maximum', '<f8'), ('negative', '?'),
           ('uncertainty_type', 'u1')])
>>> my_rng = MCRandomNumberGenerator(my_variables)
>>> my_rng.next()
array([ 2.74414022,  3.54748507])
>>> # can also be used as an interator
>>> zip(my_rng, xrange(10))
[(array([ 2.96893108,  2.90654471]), 0),
 (array([ 2.31190619,  1.49471845]), 1),
 (array([ 3.02026168,  3.33696367]), 2),
 (array([ 2.04775418,  3.68356226]), 3),
 (array([ 2.61976694,  7.0149952 ]), 4),
 (array([ 1.79914025,  6.55264372]), 5),
 (array([ 2.2389968 ,  1.11165296]), 6),
 (array([ 1.69236527,  3.24463981]), 7),
 (array([ 1.77750176,  1.90119991]), 8),
 (array([ 2.32664152,  0.84490754]), 9)]

```

# More

* Source code: https://github.com/brightway-lca/stats_arrays
* Online documentation: https://stats-arrays.readthedocs.io/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "stats-arrays",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "Chris Mutel <cmutel@gmail.com>",
    "keywords": null,
    "author": null,
    "author_email": "Chris Mutel <cmutel@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/95/39/16ae806d4293b04a3e94cb6aa8245b339c1a3a820ebf62bd3a2b946fd431/stats_arrays-0.7.tar.gz",
    "platform": null,
    "description": "The `stats_arrays` package provides a standard NumPy array interface for defining uncertain parameters used in models, and classes for Monte Carlo sampling. It also plays well with others.\n\n# Motivation\n\n* Want a consistent interface to SciPy and NumPy statistical function\n* Want to be able to quickly load and save many parameter uncertainty distribution definitions in a portable format\n* Want to manipulate and switch parameter uncertainty distributions and variables\n* Want simple Monte Carlo random number generators that return a vector of parameter values to be fed into uncertainty or sensitivity analysis\n* Want something simple, extensible, documented and tested\n\nThe `stats_arrays package was originally developed for the [Brightway2 life cycle assessment framework](https://docs.brightway.dev/), but can be applied to any stochastic model.\n\n# Example\n\n```python\n\n>>> from stats_arrays import *\n>>> my_variables = UncertaintyBase.from_dicts(\n...     {'loc': 2, 'scale': 0.5, 'uncertainty_type': NormalUncertainty.id},\n...     {'loc': 1.5, 'minimum': 0, 'maximum': 10, 'uncertainty_type': TriangularUncertainty.id}\n... )\n>>> my_variables\narray([(2.0, 0.5, nan, nan, nan, False, 3),\n       (1.5, nan, nan, 0.0, 10.0, False, 5)],\n    dtype=[('loc', '<f8'), ('scale', '<f8'), ('shape', '<f8'),\n           ('minimum', '<f8'), ('maximum', '<f8'), ('negative', '?'),\n           ('uncertainty_type', 'u1')])\n>>> my_rng = MCRandomNumberGenerator(my_variables)\n>>> my_rng.next()\narray([ 2.74414022,  3.54748507])\n>>> # can also be used as an interator\n>>> zip(my_rng, xrange(10))\n[(array([ 2.96893108,  2.90654471]), 0),\n (array([ 2.31190619,  1.49471845]), 1),\n (array([ 3.02026168,  3.33696367]), 2),\n (array([ 2.04775418,  3.68356226]), 3),\n (array([ 2.61976694,  7.0149952 ]), 4),\n (array([ 1.79914025,  6.55264372]), 5),\n (array([ 2.2389968 ,  1.11165296]), 6),\n (array([ 1.69236527,  3.24463981]), 7),\n (array([ 1.77750176,  1.90119991]), 8),\n (array([ 2.32664152,  0.84490754]), 9)]\n\n```\n\n# More\n\n* Source code: https://github.com/brightway-lca/stats_arrays\n* Online documentation: https://stats-arrays.readthedocs.io/en/latest/\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Standard NumPy array interface for defining uncertain parameters",
    "version": "0.7",
    "project_urls": {
        "homepage": "https://github.com/brightway-lca/stats_arrays",
        "source": "https://github.com/brightway-lca/stats_arrays",
        "tracker": "https://github.com/brightway-lca/stats_arrays/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45e11de3b60aaed45c7ac831cf84b17315c21014161eaa1e65112bd4043cb868",
                "md5": "15797a8faf76ad368ea1c4295d6d1b77",
                "sha256": "dcd3d827fc6192fd150b964b3d79e66e8f8e3805a0da20f20d50788c039de580"
            },
            "downloads": -1,
            "filename": "stats_arrays-0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "15797a8faf76ad368ea1c4295d6d1b77",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 26500,
            "upload_time": "2024-08-19T16:46:47",
            "upload_time_iso_8601": "2024-08-19T16:46:47.390505Z",
            "url": "https://files.pythonhosted.org/packages/45/e1/1de3b60aaed45c7ac831cf84b17315c21014161eaa1e65112bd4043cb868/stats_arrays-0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "953916ae806d4293b04a3e94cb6aa8245b339c1a3a820ebf62bd3a2b946fd431",
                "md5": "9cd2e23e4f864f6eee5b2375615dfd40",
                "sha256": "cf3987736997974dc7988711a3757d2d9b9ef4d252f5e3ca2e83a5b474e6ae39"
            },
            "downloads": -1,
            "filename": "stats_arrays-0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "9cd2e23e4f864f6eee5b2375615dfd40",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 30480,
            "upload_time": "2024-08-19T16:46:49",
            "upload_time_iso_8601": "2024-08-19T16:46:49.175276Z",
            "url": "https://files.pythonhosted.org/packages/95/39/16ae806d4293b04a3e94cb6aa8245b339c1a3a820ebf62bd3a2b946fd431/stats_arrays-0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-19 16:46:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "brightway-lca",
    "github_project": "stats_arrays",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stats-arrays"
}
        
Elapsed time: 0.44133s