New statistical library: stats_arrays

A new way to work with and store uncertainty values

Numbers. Just some numbers. Really.

Figure 1: Numbers. Credit: eye/see.

One of the few good ideas to come out of the original Brightway program (see the technical motivation for Brightway2) is the use of parameter arrays, which store uncertain variable definitions in a NumPy array. This functionality was factored out into bw_stats_toolkit.

Today was the first release of stats_arrays, which is the basically same thing, except only better. The core idea remains the same.

See an example of the new library in action.

Here are the improvements:

  • There is no need to transform values in the amount column when doing stochastic and non-stochastic sampling. Instead, there are separate amount and loc columns. This makes for simpler and easier to test code.
  • There are now three columns for statistical parameters, allowing for more uncertainty distributions.
  • Uncertainty fields now follow semi-standardized names: loc, scale, and shape, instead of amount and sigma.
  • More uncertainty distributions.
  • There is documentation and more complete tests.

Check out the source code and documentation.

Upgrading to stats_arrays

Install stats_arrays using pip or another Python package manager. For most of you, this will mean:

pip install stats_arrays

You will also need to upgrade bw2data and bw2calc:

pip install --upgrade --no-deps bw2calc bw2data

Then, run the following in a Python shell:

from bw2data.utils import convert_from_stats_toolkit