Batch sampling from a Distribution
Name
UxHwDoubleSampleBatch, UxHwFloatSampleBatch — Store a batch of samples from a distribution to a destination array.
Synopsis
#include <stddef.h>
#include <uxhw.h>
void UxHwDoubleSampleBatch(double value, double * destSampleArray, size_t numberOfRandomSamples);
void UxHwFloatSampleBatch(float value, float * destSampleArray, size_t numberOfRandomSamples);
Description
The UxHwDoubleSampleBatch() function, on architectures that associate distributional information with floating-point values, draws numberOfRandomSamples random samples from the distribution associated with value and stores them in the destination array destSampleArray.
Parameters
value— The distributional value to draw samples from.destSampleArray— The destination array where the samples will be stored.numberOfRandomSamples— The number of samples to be drawn and stored.
Return Values
The UxHwDoubleSampleBatch() function does not return a value.
✏️ Examples
#include <stddef.h>
#include <stdio.h>
#include <uxhw.h>
enum
{
N = 10,
};
int
main(void)
{
size_t i;
double a;
double samples[N] = {0};
a = UxHwDoubleUniformDist(10.0, 20.0);
UxHwDoubleSampleBatch(a, samples, N);
for (i = 0; i < 10; i++)
{
printf("Sample %d of %lf is %lf.\n", i, a, samples[i]);
}
return 0;
}