|
| | PiecewiseConstantDistribution () |
| | Default constructor. Creates uniform distribution over [0, 1).
|
| |
| template<typename InputIteratorB , typename InputIteratorW > |
| | PiecewiseConstantDistribution (InputIteratorB first_b, InputIteratorB last_b, InputIteratorW first_w) |
| | Constructs from interval boundaries and density weights.
|
| |
| template<typename UnaryOperation > |
| | PiecewiseConstantDistribution (std::initializer_list< RealType > bl, UnaryOperation fw) |
| | Constructs from interval boundaries and weight function.
|
| |
| template<typename UnaryOperation > |
| | PiecewiseConstantDistribution (size_t nw, RealType xmin, RealType xmax, UnaryOperation fw) |
| | Constructs with evenly-spaced intervals and weight function.
|
| |
| | PiecewiseConstantDistribution (const param_type ¶m) |
| | Constructs from a parameter set.
|
| |
| void | reset () |
| | Resets the distribution state.
|
| |
| std::vector< RealType > | intervals () const |
| | Returns the interval boundaries.
|
| |
| std::vector< double > | densities () const |
| | Returns the density values.
|
| |
| param_type | param () const |
| | Gets the current parameter set.
|
| |
| void | param (const param_type ¶m) |
| | Sets new parameters for the distribution.
|
| |
| result_type | min () const |
| | Gets the minimum value that can be generated.
|
| |
| result_type | max () const |
| | Gets the maximum value that can be generated.
|
| |
| template<typename Generator > |
| result_type | operator() (Generator &g) |
| | Generates the next random value using stored parameters.
|
| |
| template<typename Generator > |
| result_type | operator() (Generator &g, const param_type ¶m) |
| | Generates the next random value using provided parameters.
|
| |
template<typename RealType = double>
class Infinity::Engine::PiecewiseConstantDistribution< RealType >
Platform-independent piecewise constant distribution.
Produces real values from a distribution defined by a piecewise constant density function. The range is divided into intervals, each with a constant probability density, allowing you to approximate arbitrary probability distributions or create custom probability landscapes for procedural generation.
This distribution is extremely useful for creating non-uniform spatial distributions, modeling multi-modal data, approximating complex probability distributions, or implementing custom probability functions that can't be expressed with standard distributions.
- Template Parameters
-
| RealType | Floating point type (float or double) |
Example usage:
std::vector<float>
intervals = {0.0f, 1.0f, 2.0f, 3.0f};
std::vector<double>
densities = {0.5, 2.0, 0.5};
);
float value = dist(rng);
{0.0f, 100.0f, 500.0f, 1000.0f},
[](float x) { return x < 250.0f ? 1.0 : 0.3; }
);
auto density_fn = [](double x) {
return (x > 0.3 && x < 0.7) ? 5.0 : 1.0;
};
Pseudo-random number generator for procedural generation.
Definition PRNG.hpp:48
std::vector< double > densities() const
Returns the density values.
Definition PRNGDistribution.hpp:4124
std::vector< RealType > intervals() const
Returns the interval boundaries.
Definition PRNGDistribution.hpp:4121
template class INFINITY_API_PUBLIC PiecewiseConstantDistribution< float >
Definition PRNGDistribution.cpp:65
template class INFINITY_API_PUBLIC PiecewiseConstantDistribution< double >
Definition PRNGDistribution.cpp:66
- Note
- Densities are automatically normalized to integrate to 1.
-
Returns values within the specified interval range.
-
Each interval has constant density - use PiecewiseLinearDistribution for smooth transitions.
-
Useful for approximating empirical distributions or complex PDFs.