Distribution from Samples
Name
UxHwDoubleDistFromSamples
, UxHwFloatDistFromSamples
— Create a distributional value from an array of samples.
Synopsis
#include <stddef.h>
#include <uxhw.h>
double UxHwDoubleDistFromSamples(double * samples, size_t sampleCount);
float UxHwFloatDistFromSamples(float * samples, size_t sampleCount);
Description
The UxHwDoubleDistFromSamples()
function returns the mean value of the first sampleCount
elements of the samples
array.
On architectures that associate distributional information with floating-point values, also creates a distributional value that follows the empirical distribution of the first sampleCount
elements in the samples
array.
On such architectures, the return value is associated, at the architecture level, with the distributional value created and it is equal with the mean value of the distribution.
Parameters
samples
— The pointer to the array of floating-point values to sample from.sampleCount
— The number of elements of the array that are going to be used for the calculation of the distributional value and its mean.
Return Values
The UxHwDoubleDistFromSamples()
function returns the mean value of the first sampleCount
elements of the samples
array. If sampleCount
is equal to 0, the function returns NaN
.
✏️ Examples
#include <stdio.h>
#include <stddef.h>
#include <uxhw.h>
enum
{
N = 2,
};
int
main(void)
{
double a;
double samples[N] = {1.0, 3.0};
a = UxHwDoubleDistFromSamples(samples, N);
printf("a = %lf\n", a);
return 0;
}