jpt.distributions.univariate.numeric
© Copyright 2021, Mareike Picklum, Daniel Nyga.
Classes
Values -> Labels |
|
Labels -> Values |
|
Wrapper class for numeric domains and distributions. |
|
Scaled numeric distribution represented by mean and variance. |
Functions
|
Module Contents
- class jpt.distributions.univariate.numeric.NumericMap(mean: float = None, scale: float = None)
Bases:
jpt.distributions.univariate.distribution.ValueMap- mean = None
- scale = None
- fit(data: numpy.ndarray) NumericMap
- to_json() Dict[str, Any]
- classmethod from_json(data: Dict[str, Any]) NumericMap
- __hash__()
- __eq__(other)
- class jpt.distributions.univariate.numeric.NumericValueToLabelMap(mean: float = None, scale: float = None)
Bases:
NumericMapValues -> Labels
- __getitem__(x) float
- transform(x, make_copy=True) numpy.ndarray | float
- class jpt.distributions.univariate.numeric.NumericLabelToValueMap(mean: float = None, scale: float = None)
Bases:
NumericMapLabels -> Values
- __getitem__(x) float
- transform(x, make_copy=True) numpy.ndarray | float
- class jpt.distributions.univariate.numeric.Numeric(**settings)
Bases:
jpt.distributions.univariate.DistributionWrapper class for numeric domains and distributions.
- PRECISION = 'precision'
- values
- labels
- SETTINGS
- _quantile: jpt.distributions.qpd.QuantileDistribution = None
- to_json
- classmethod hash()
- __str__()
- __getitem__(value)
- classmethod value2label(value: float | jpt.base.intervals.NumberSet) float | jpt.base.intervals.NumberSet
- classmethod label2value(label: numbers.Real | jpt.base.intervals.NumberSet) numbers.Real | jpt.base.intervals.NumberSet
- classmethod equiv(other)
- property cdf
- property pdf
- property ppf
- approximate_fast(eps: float)
- _sample(n)
- _sample_one()
- number_of_parameters() int
- Returns:
The number of relevant parameters in this decision node. 1 if this is a dirac impulse, number of intervals times two else
- _expectation() float
- _variance() float
- expectation() float
- variance() float
- quantile(gamma: numbers.Real) numbers.Real
- create_dirac_impulse(value)
Create a dirac impulse at the given value aus quantile distribution.
- is_dirac_impulse() bool
Checks if this distribution is a dirac impulse.
- mpe()
- _mpe(value_transform: Callable | None = None)
Calculate the most probable configuration of this quantile distribution.
- Returns:
The mpe itself as UnionSet and the likelihood of the mpe as float
- _k_mpe(k: int | None = None) List[Tuple[jpt.base.intervals.NumberSet, float]]
Calculate the
kmost probable explanation states.- Parameters:
k – The number of solutions to generate, defaults to the maximum possible number.
- Returns:
A list containing a tuple containing the likelihood and state in descending order.
- k_mpe(k: int | None = None) List[Tuple[jpt.base.intervals.NumberSet, float]]
Calculate the
kmost probable explanation states.- Parameters:
k – The number of solutions to generate, defaults to the maximum possible number.
- Returns:
A list containing a tuple containing the likelihood and state in descending order.
- fit
- _p(value: numbers.Number | jpt.base.intervals.NumberSet) numbers.Real
- p(labels: numbers.Number | jpt.base.intervals.NumberSet | List[float]) numbers.Real
- copy()
- _crop(restriction: jpt.base.intervals.NumberSet | numbers.Number) Numeric
Apply a restriction to this distribution. The restricted distrubtion will only assign mass to the given range and will preserve the relativity of the pdf.
- Parameters:
restriction (float or int or ContinuousSet) – The range to limit this distribution (or singular value)
- classmethod type_to_json()
- inst_to_json()
- static from_json(data)
- classmethod type_from_json(data: Dict[str, Any])
- insert_convex_fragments(left: jpt.base.intervals.ContinuousSet | None, right: jpt.base.intervals.ContinuousSet | None, number_of_samples: int)
Insert fragments of distributions on the right and left part of this distribution. This should only be used to create a convex hull around the JPTs domain which density is never 0.
- Parameters:
right – The right (lower) interval to add on if needed and None else
left – The left (upper) interval to add on if needed and None else
number_of_samples – The number of samples to use as basis for the weight
- classmethod cumsum(distributions: Iterable[Numeric], error_max: float = np.inf, n_segments: int = None) Iterable[Numeric]
Generator yielding the distributions that correspond to the cumulative sums of the passed distributions.
- Parameters:
distributions –
error_max –
n_segments –
- Returns:
- moment(order: int, center: float) float
- _moment(order: int, center: float, value_transform: Callable | None = None) float
Calculate the central moment of the r-th order almost everywhere.
\[\int (x - c)^{r} p(x)\]- Parameters:
order – The order of the moment to calculate
center – The constant to subtract in the basis of the exponent If center is 0, the result corresponds to the
order-th raw moment. If center is set to the distributions mean (ie its expectation, or self._moment(1, 0)) the result is the central moment of the distribution.
- entropy() float
- plot(engine=None, **kwargs) Any
Plots the distribution using the given engine.
- Parameters:
engine – Can be either one of
["plotly", "matplotlib"], or an instance of a rendering engine subclassingDistributionRendering.kwargs – The keyword arguments to pass to the engine as defined in the
.plot_numeric()function ofDistributionRenderingor its respective subclass defined byengine.
- Returns:
the figure object of the plotting engine