Skip to main content

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

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-3.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stats_arrays-3.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stats_arrays-3.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for stats_arrays-3.0.tar.gz
Algorithm Hash digest
SHA256 4c213dbfbffad81027f8a87df4d4fcc580ee9661af7a6ea11fe2309211bd6c37
MD5 edf5129f163637f68a9b25eb7877cf83
BLAKE2b-256 4ef9299731496198ff7080b3e8cca0e0c9c5bbb3f0ae76e3b609f5de2c62c047

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stats_arrays-3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for stats_arrays-3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc205c317f767b2210331a31c2765751b40f10c9140336c6e83956c9d667c606
MD5 a79d4ec288cbe45b96822181f488a7d6
BLAKE2b-256 81be4512d77bf83ed7f1a454f96f2bea80cecbe725b23e8f9186a6661abacf80

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0 This release

2 files

2.0

2 files

1.0

2 files

0.8

2 files

0.7

2 files

0.6.6

2 files

0.6.5

2 files

0.6.4

1 file

0.6.3

1 file

0.6.2

1 file

0.6.1

2 files

0.6

2 files

0.5.1

2 files

0.5

2 files

0.4.2

2 files

0.4.1

2 files

0.4

2 files

0.3.2

2 files

0.3.1

2 files

0.3

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page