|
Marine systems simulation
|
#include <CumulativeDistribution.h>
Public Types | |
| using | probabilityDensity = std::function< double(double)> |
| Signature for functions used to define probability density functions. | |
Public Member Functions | |
| CumulativeDistribution (probabilityDensity pdf, double xMin, double xMax, int numBins) | |
| double | ValueAtCumulativeProbability (double probability) const |
Cumulative distribution built from a probability density function (PDF) on a closed interval.
The interval \([x_{\min}, x_{\max}]\) is discretized into \(N\) uniform bins with width \(h = (x_{\max}-x_{\min})/N\). Let \(p_i \approx \int_{x_i}^{x_{i+1}} f(x)\,dx\) be the bin probability masses obtained by (e.g.) midpoint rule. The cumulative distribution is \(F_k = \sum_{i=0}^{k-1} p_i\) with \(F_0=0\) and \(F_N=1\) after normalization.
This class stores the cumulative (CDF) samples and supports efficient inverse lookup: for a given cumulative probability \(u \in [0,1]\), return the corresponding \(x\) (piecewise linear within a bin).
| marenv::calc::CumulativeDistribution::CumulativeDistribution | ( | probabilityDensity | pdf, |
| double | xMin, | ||
| double | xMax, | ||
| int | numBins | ||
| ) |
Constructor.
| The probability density function. | |
| xMin | The minimum x value. |
| xMax | The maximum x value. |
| numBins | The number of bins to use for the integration. |
| double marenv::calc::CumulativeDistribution::ValueAtCumulativeProbability | ( | double | probability | ) | const |
Calculates the x value which has a certain cumulative probability.
| probability | Cumulative probability. |