Skip to main content

Sampling from a Distribution

Name​

UxHwDoubleSample, UxHwFloatSample — Return a sample from the distribution.

Synopsis​

#include <uxhw.h>

double UxHwDoubleSample(double value);
float UxHwFloatSample(float value);

Description​

The UxHwDoubleSample() function, on architectures that associate distributional information with floating-point values, draws a sample from the distribution associated with value and returns it.

Parameters​

  • value — The distributional value to draw a sample from.

Return values​

The UxHwDoubleSample() function returns a sample from the distribution value. If value has no distribution associated with it, it returns value.

If value is NaN with no associated distribution, the function returns -NaN. If the distribution associated with value carries NaN mass, the function returns -NaN with a probability equal to that mass. See Handling of NaN.

Examples​

#include <stdio.h>
#include <uxhw.h>

int
main(void)
{
double a = UxHwDoubleUniformDist(10.0, 20.0);
double sample = UxHwDoubleSample(a);

printf("Sample of %lf is %lf.\n", a, sample);

return 0;
}