pyuncertainnumber.pba.pbox_free¶
Attributes¶
Functions¶
|
construct free pbox from sample data by Kolmogorov-Smirnoff confidence bounds |
|
Construct a uncertain number given known statistical properties served as constraints. |
|
Equivalent to an interval object constructed as a nonparametric Pbox. |
|
Nonparametric pbox construction based on constraint of minimum and mean |
|
Nonparametric pbox construction based on constraint of mean and std |
|
Nonparametric pbox construction based on constraint of mean and var |
|
Generates a distribution-free p-box based upon the minimum, maximum and mean of the variable |
|
Generates a positive distribution-free p-box based upon the mean and standard deviation of the variable |
|
Nonparametric pbox construction based on constraint of mean and var |
|
Generates a distribution-free p-box based upon the minimum, maximum and median of the variable |
|
Generates a distribution-free p-box based upon the minimum, maximum, mean and standard deviation of the variable |
|
Generates a distribution-free p-box based upon the minimum, maximum, mean and standard deviation of the variable |
|
yields a distribution-free p-box based on specified percentiles of the variable |
Module Contents¶
- pyuncertainnumber.pba.pbox_free.KS_bounds(s: numpy.typing.ArrayLike, alpha: float, display=True, output_type='bounds') tuple[pyuncertainnumber.pba.ecdf.eCDF_bundle] | pyuncertainnumber.pba.pbox_abc.Pbox | pyuncertainnumber.UncertainNumber¶
construct free pbox from sample data by Kolmogorov-Smirnoff confidence bounds
- Parameters:
s (ArrayLike) – sample data, precise and imprecise
dn (float) – KS critical value at a significance level and sample size N;
output_type (str) – A choice between {‘bounds’, ‘pbox’, ‘un’}, default=’bounds’ which returns two eCDF bundles as bounds; ‘pbox’ to return a pbox object; ‘un’ to return an uncertain number object.
- Returns:
a tuple of two CDF bounds, i.e. upper and lower (eCDF_bundle objects), or a Pbox object, or an UncertainNumber object the return type is controlled by the output_type argument.
Note
By default the function returns two eCDF bundles as the extreme bounds. With the upper and lower bounds, a free pbox can be constructed.
Example
>>> # both precise data (e.g. numpy array) and imprecise data (e.g. a vector of interval) are supported >>> precise_data = np.random.normal(0, 1, 100) # precise data case >>> ub, lb = pba.KS_bounds(precise_data, alpha=0.025, display=True)
>>> # alternatively, an uncertain number or a p-box can be returned >>> pba.KS_bounds(precise_data, alpha=0.025, display=False, output_type='pbox') # return a pbox object >>> pba.KS_bounds(precise_data, alpha=0.025, display=False, output_type='un') # return an uncertain number object
>>> # imprecise data case >>> impre_data = pba.I(lo = precise_data -0.5, hi = precise_data + 0.5) >>> ub, lb = pba.KS_bounds(impre_data, alpha=0.025, display=True)
Kolmogorov-Smirnoff confidence bounds illustration with precise and imprecise data.¶
- pyuncertainnumber.pba.pbox_free.known_properties(maximum=None, mean=None, median=None, minimum=None, mode=None, percentiles=None, std=None, var=None, family=None, **kwargs) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber¶
Construct a uncertain number given known statistical properties served as constraints.
- Parameters:
maximum (number) – maximum value of the variable
mean (number) – mean value of the variable
median (number) – median value of the variable
minimum (number) – minimum value of the variable
mode (number) – mode value of the variable
percentiles (dict) – dictionary of percentiles and their values, e.g. {0: 0, 0.1: 1, 0.5: 2, 0.9: pun.I(3,4), 1:5}
std (number) – standard deviation of the variable
var (number) – variance of the variable
family (str) – name of the distribution family, e.g. ‘normal’, ‘lognormal’, ‘uniform’, ‘triangular’, etc.
- Returns:
uncertain number
Note
It’s also possible to directly call a function given the known information, such as
pun.mean_std(mean=1, std=0.5).Example
>>> from pyuncertainnumber.pba import known_properties >>> known_properties( ... maximum = 2, ... mean = 1, ... var = 0.25, ... minimum=0, ... )
- pyuncertainnumber.pba.pbox_free.known_constraints¶
- pyuncertainnumber.pba.pbox_free.min_max(minimum: numbers.Number, maximum: numbers.Number) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Equivalent to an interval object constructed as a nonparametric Pbox.
- Parameters:
minimum – Left end of box
maximum – Right end of box
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> from pyuncertainnumber.pba import min_max >>> min_max(0, 2) # return a UncertainNumber >>> min_max(0, 2, return_construct=True) # return a Pbox
- pyuncertainnumber.pba.pbox_free.min_mean(minimum, mean, steps=Params.steps) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Nonparametric pbox construction based on constraint of minimum and mean
- Parameters:
minimum (number) – minimum value of the variable
mean (number) – mean value of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> from pyuncertainnumber.pba import min_mean >>> min_mean(0, 1) # return a UncertainNumber >>> min_mean(0, 1, return_construct=True) # return a Pbox
- pyuncertainnumber.pba.pbox_free.mean_std(mean: numbers.Number, std: numbers.Number, steps=Params.steps) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Nonparametric pbox construction based on constraint of mean and std
- Parameters:
mean (number) – mean value of the variable
std (number) – std value of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> mean_std(1, 0.5)
- pyuncertainnumber.pba.pbox_free.mean_var(mean: numbers.Number, var: numbers.Number) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Nonparametric pbox construction based on constraint of mean and var
- Parameters:
mean (number) – mean value of the variable
vasr (number) – var value of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> mean_var(1, 0.25) # return a UncertainNumber
- pyuncertainnumber.pba.pbox_free.min_max_mean(minimum: numbers.Number, maximum: numbers.Number, mean: numbers.Number, steps: int = Params.steps) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Generates a distribution-free p-box based upon the minimum, maximum and mean of the variable
- Parameters:
minimum (float) – minimum value of the variable
maximum (float) – maximum value of the variable
mean (float) – mean value of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> min_max_mean(0, 2, 1)
- pyuncertainnumber.pba.pbox_free.pos_mean_std(mean: numbers.Number, std: numbers.Number, steps=Params.steps) pyuncertainnumber.pba.pbox_abc.Pbox¶
Generates a positive distribution-free p-box based upon the mean and standard deviation of the variable
- Parameters:
mean – mean of the variable
std – standard deviation of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
- pyuncertainnumber.pba.pbox_free.min_max_mode(minimum: numbers.Number, maximum: numbers.Number, mode: numbers.Number, steps: int = Params.steps) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Nonparametric pbox construction based on constraint of mean and var
- Parameters:
minimum – minimum value of the variable
maximum – maximum value of the variable
mode (number) – mode value of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> min_max_mode(0, 2, 1) # return a UncertainNumber
- pyuncertainnumber.pba.pbox_free.min_max_median(minimum: numbers.Number, maximum: numbers.Number, median: numbers.Number, steps: int = Params.steps) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Generates a distribution-free p-box based upon the minimum, maximum and median of the variable
- Parameters:
minimum – minimum value of the variable
maximum – maximum value of the variable
median – median value of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> min_max_median(0, 2, 1) # return a UncertainNumber
- pyuncertainnumber.pba.pbox_free.min_max_mean_std(minimum: numbers.Number, maximum: numbers.Number, mean: numbers.Number, std: numbers.Number, **kwargs) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Generates a distribution-free p-box based upon the minimum, maximum, mean and standard deviation of the variable
- Parameters:
maximum (number) – maximum value of the variable
minimum (number) – minimum value of the variable
std (number) – standard deviation of the variable
var (number) – variance of the variable
- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> min_max_mean_std(0, 2, 1, 0.5) # return a UncertainNumber
See also
- pyuncertainnumber.pba.pbox_free.min_max_mean_var(minimum: numbers.Number, maximum: numbers.Number, mean: numbers.Number, var: numbers.Number, **kwargs) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
Generates a distribution-free p-box based upon the minimum, maximum, mean and standard deviation of the variable
- Parameters:
minimum (number) – minimum value of the variable
maximum (number) – maximum value of the variable
mean (number) – mean value of the variable
var (number) – variance of the variable
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> min_max_mean_var(0, 2, 1, 0.25) # return a UncertainNumber
Implementation
Equivalent to
min_max_mean_std(minimum,maximum,mean,np.sqrt(var))See also
- pyuncertainnumber.pba.pbox_free.from_percentiles(percentiles: dict, steps: int = Params.steps) pyuncertainnumber.characterisation.uncertainNumber.UncertainNumber | pyuncertainnumber.pba.pbox_abc.Pbox¶
yields a distribution-free p-box based on specified percentiles of the variable
- Parameters:
percentiles – dictionary of percentiles and their values (e.g. {0: 0, 0.1: 1, 0.5: 2, 0.9: I(3,4), 1:5})
steps – number of steps to use in the p-box
Note
The percentiles dictionary is of the form {percentile: value}. Where value can either be a number or an I. If value is a number, the percentile is assumed to be a point percentile. If value is an I, the percentile is assumed to be an interval percentile. If no keys for 0 and 1 are given,
-np.infandnp.infare used respectively. This will result in a p-box that is not bounded and raise a warning. If the percentiles are not increasing, the percentiles will be intersected. This may not be desired behaviour. ValueError: If any of the percentiles are not between 0 and 1.- Returns:
UncertainNumber or Pbox
Tip
Two types of return values are possible:
by default, a UncertainNumber is returned;
For low-level controls, if return_construct=True is specified, a Pbox is returned.
Example
>>> pba.from_percentiles( >>> {0: 0, >>> 0.25: 0.5, >>> 0.5: pba.I(1,2), >>> 0.75: pba.I(1.5,2.5), >>> 1: 3}) >>> .display()