The OpenD Programming Language

Flex

Data body of the Flex algorithm. Can be used to sample from the distribution.

static if(is(typeof( )))
@RandomVariable
struct Flex (
S
Pdf
) if (
isFloatingPoint!S
) {}

Members

Functions

intervals
const(FlexInterval!S[]) intervals()

Generated partition points

opCall
S opCall(RNG rng)

Sample a value from the distribution.

Examples

import mir.math : approxEqual;
import std.meta : AliasSeq;
import mir.random.engine.xorshift : Xorshift;
auto gen = Xorshift(42);
alias S = double;
auto f0 = (S x) => -x^^4 + 5 * x^^2 - 4;
auto f1 = (S x) => 10 * x - 4 * x^^3;
auto f2 = (S x) => 10 - 12 * x^^2;
S[] points = [-3, -1.5, 0, 1.5, 3];

auto tf = flex(f0, f1, f2, 1.5, points, 1.1);
auto value = tf(gen);

Meta