pyuncertainnumber.pba.aggregation

Functions

envelope(...)

calculates the envelope of constructs only

imposition(...)

Returns the imposition/intersection of the list of p-boxes

stochastic_mixture(*l_uns[, weights])

it could work for either Pbox, distribution, DS structure or Intervals

stacking(→ pyuncertainnumber.pba.pbox_abc.Pbox)

stochastic mixture operation of Intervals with probability masses

mixture_pbox(→ pyuncertainnumber.pba.pbox_abc.Pbox)

mixture_ds(→ pyuncertainnumber.pba.dss.DempsterShafer)

mixture operation for DS structure

env_samples(data[, output_type, ecdf_choice])

nonparametric envelope function directly from data samples

env_ecdf_sep(*ecdfs[, output_type, ecdf_choice])

nonparametric envelope function for separate empirical CDFs

env_am(→ numpy.ndarray)

bespoke function used for am metric case

env_pbox_am(→ numpy.ndarray)

bespoke function used for am metric case

Module Contents

pyuncertainnumber.pba.aggregation.envelope(*l_uns: pyuncertainnumber.pba.pbox_abc.Pbox | pyuncertainnumber.pba.dss.DempsterShafer | numbers.Number | pyuncertainnumber.pba.intervals.Interval | pyuncertainnumber.pba.distributions.Distribution | pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber, output_type='pbox') pyuncertainnumber.pba.pbox_abc.Staircase | pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber

calculates the envelope of constructs only

Parameters:
  • l_uns (list) – the components, constructs and uncertain numbers, on which the envelope operation applied on.

  • output_type (str) – {‘pbox’ or ‘uncertain_number’ or ‘un’} - default is pbox

Returns:

the envelope of the given arguments, either a p-box or an interval.

Example

>>> from pyuncertainnumber import envelope
>>> a = pba.normal(3, 1)
>>> b = pba.uniform(5, 8)
>>> c = pba.normal(13, 2)
>>> t = envelope(a, b, c, output_type='pbox') # or output_type='uncertain_number'
pyuncertainnumber.pba.aggregation.imposition(*l_uns: pyuncertainnumber.pba.pbox_abc.Pbox | pyuncertainnumber.pba.dss.DempsterShafer | numbers.Number | pyuncertainnumber.pba.intervals.Interval | pyuncertainnumber.pba.distributions.Distribution | pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber, output_type='pbox') pyuncertainnumber.pba.pbox_abc.Staircase | pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber

Returns the imposition/intersection of the list of p-boxes

Parameters:
  • l_uns (list) – a list of constructs or UN objects to be mixed

  • output_type (str) – {‘pbox’ or ‘uncertain_number’ or ‘un’} - default is pbox

Returns:

  • Pbox or UncertainNumber

Example

>>> import pyuncertainnumber as pun
>>> from pyuncertainnumber import pba
>>> a = pba.normal([3, 7], 1)
>>> b = pba.uniform([3,5], [6,9])
>>> i = pun.imposition(a, b)
pyuncertainnumber.pba.aggregation.stochastic_mixture(*l_uns: pyuncertainnumber.pba.pbox_abc.Pbox | pyuncertainnumber.pba.dss.DempsterShafer | numbers.Number | pyuncertainnumber.pba.intervals.Interval | pyuncertainnumber.pba.distributions.Distribution | pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber, weights=None)

it could work for either Pbox, distribution, DS structure or Intervals

Parameters:
  • l_uns (-) – list of constructs or uncertain numbers

  • weights (-) – list of weights

Example

>>> import pyuncertainnumber as pun
>>> p = pun.stochastic_mixture([[1,3], [2,4]])
pyuncertainnumber.pba.aggregation.stacking(vec_interval: pyuncertainnumber.pba.intervals.Interval | list[pyuncertainnumber.pba.intervals.Interval], *, weights=None, display=False, ax=None, return_type='pbox', **kwargs) pyuncertainnumber.pba.pbox_abc.Pbox

stochastic mixture operation of Intervals with probability masses

Parameters:
  • vec_interval (-) – list of Intervals or a vectorised Interval

  • weights (-) – list of weights

  • display (-) – boolean for plotting

  • return_type (-) – {‘pbox’ or ‘ds’ or ‘bounds’}

Returns:

by default a p-box but can return the left and right bound F in eCDF_bundlebounds.

Note

  • For intervals specifically.

  • it takes a list of intervals or a single vectorised interval, which is

a different signature compared to the other aggregation functions. - together the interval and masses, it can be deemed that all the inputs required is jointly a DS structure

Example

>>> stacking([[1,3], [2,4]], weights=[0.5, 0.5], display=True)
pyuncertainnumber.pba.aggregation.mixture_pbox(*l_pboxes, weights=None, display=False) pyuncertainnumber.pba.pbox_abc.Pbox
pyuncertainnumber.pba.aggregation.mixture_ds(*l_ds, display=False) pyuncertainnumber.pba.dss.DempsterShafer

mixture operation for DS structure

pyuncertainnumber.pba.aggregation.env_samples(data: numpy.typing.ArrayLike, output_type='pbox', ecdf_choice='canonical')

nonparametric envelope function directly from data samples

Parameters:
  • data (ArrayLike) – Each row represents a distribution, on which the envelope operation applied.

  • output_type (str) – {‘pbox’ or ‘cdf’} default is pbox cdf is the CDF bundle

  • ecdf_choice (str) – {‘canonical’ or ‘staircase’}

Note

envelope on a set of empirical CDFs

pyuncertainnumber.pba.aggregation.env_ecdf_sep(*ecdfs, output_type='pbox', ecdf_choice='canonical')

nonparametric envelope function for separate empirical CDFs

pyuncertainnumber.pba.aggregation.env_am(n_pars: numpy.typing.ArrayLike) numpy.ndarray

bespoke function used for am metric case

Parameters:

n_pars (ArrayLike) – (n_sam, 2) of tuple (mu, sigma) which may be a tensor

pyuncertainnumber.pba.aggregation.env_pbox_am(n_mean: numpy.typing.ArrayLike, n_std: numpy.typing.ArrayLike) numpy.ndarray

bespoke function used for am metric case

Parameters:
  • n_mean (ArrayLike) – (n_sam,) of mean values which may be a tensor

  • n_std (ArrayLike) – (n_sam,) of standard deviation values which may be a tensor