Skip to main content

Standard NumPy array interface for defining uncertain parameters

Project 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.

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, but can be applied to any stochastic model.

Example

>>> 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stats_arrays-0.7.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

stats_arrays-0.7-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file stats_arrays-0.7.tar.gz.

File metadata

  • Download URL: stats_arrays-0.7.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.14

File hashes

Hashes for stats_arrays-0.7.tar.gz
Algorithm Hash digest
SHA256 cf3987736997974dc7988711a3757d2d9b9ef4d252f5e3ca2e83a5b474e6ae39
MD5 9cd2e23e4f864f6eee5b2375615dfd40
BLAKE2b-256 953916ae806d4293b04a3e94cb6aa8245b339c1a3a820ebf62bd3a2b946fd431

See more details on using hashes here.

File details

Details for the file stats_arrays-0.7-py3-none-any.whl.

File metadata

  • Download URL: stats_arrays-0.7-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.14

File hashes

Hashes for stats_arrays-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 dcd3d827fc6192fd150b964b3d79e66e8f8e3805a0da20f20d50788c039de580
MD5 15797a8faf76ad368ea1c4295d6d1b77
BLAKE2b-256 45e11de3b60aaed45c7ac831cf84b17315c21014161eaa1e65112bd4043cb868

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page