DistNormalTrunc
- class pydsol.core.distributions.DistNormalTrunc(stream: StreamInterface, mu: float = 0.0, sigma: float = 1.0, lo: float = -inf, hi: float = inf)[source]
Bases:
DistContinuous
The Truncated Normal distribution. For more information on the truncated normal distribution see: https://en.wikipedia.org/wiki/Truncated_normal_distribution.
- __init__(stream: StreamInterface, mu: float = 0.0, sigma: float = 1.0, lo: float = -inf, hi: float = inf)[source]
Constructs a new Truncated Normal distribution, with two parameters mu for the mean, and sigma for the standard deviation. A lo and hi x-value indicate where the distribution will be ‘cut off’.
- Parameters:
stream (StreamInterface) – the random stream to use for this distribution
mu (float or int) – the mean of the Normal distribution, , before applying the cutoff by the lo and hi values
sigma (float or int) – the standard deviation of the Normal distribution, before applying the cutoff by the lo and hi values
lo (float or int) – lowest value of the ‘remaining’ distribution
hi (float or int) – highest value of the ‘remaining’ distribution
- Raises:
TypeError – when stream is not implementing StreamInterface:
TypeError – when mu, sigma, lo or hi are not float or int:
ValueError – when sigma <= 0:
ValueError – when max <= min:
ValueError – when the probabilities are so small that drawing becomes: impossible. The cutoff point is at an interval with an overall probability of less than 1E-6
- draw() float [source]
Draw a value from the Normal distribution with mean mu and standard deviation sigma on the interval (lo, hi)
- cumulative_probability(x: float) float [source]
Return the cumulative probability of x for the truncated distribution
- cumulative_probability_not_truncated(x: float) float [source]
Return the cumulative probability of x for the non-truncated distribution
- inverse_cumulative_probability(y: float) float [source]
Return the x-value of the given cumulative probability y for the truncated distribution.
- inverse_cumulative_probability_not_truncated(y: float) float [source]
Return the x-value of the given cumulative probability y for the non-truncated distribution.
- property mu: float
Return the parameter value mu, the mean of the Normal distribution
- property sigma: float
Return the parameter value sigma, the standard deviation of the Normal distribution
- property lo: float
Return the lower bound of the truncated distribution
- property hi: float
Return the upper bound of the truncated distribution
- property stream: StreamInterface
Return the current random stream for this distribution.