Mixture of Distributions
Name
UxHwDoubleMixture
, UxHwFloatMixture
— Calculate the Mixture of two distributions.
Synopsis
#include <uxhw.h>
double UxHwDoubleMixture(double a, double b, double aScale);
float UxHwFloatMixture(float a, float b, float aScale);
Description
The UxHwDoubleMixture()
function, on architectures that associate distributional information with floating-point variables, creates a distributional value that follows the mixture distribution generated from the distributional values associated with a
and b
, and associates it with its return value. The resulting mixture distribution contains the distribution of a
with probability aScale
and the distribution of b
with probability 1 - aScale
. The function returns the mean value of the outcome mixture distribution.
Parameters
a
— The distributional value of this parameter is used for the calculation of the mixture distribution.b
— The distributional value of this parameter is used for the calculation of the mixture distribution.aScale
— The scaling ofa
distribution in the resulting mixture distribution. Its value must be in [0.0, 1.0].
Return Values
The UxHwDoubleMixture()
function returns the mean value of the samples drawn from the mixture distribution of a
and b
, with scaling aScale
. If the value of aScale
is not in [0.0, 1.0], the function returns NaN
.
✏️ Examples
#include <stdio.h>
#include <uxhw.h>
int
main(void)
{
double a = UxHwDoubleUniformDist(0.0, 10.0);
double b = UxHwDoubleUniformDist(5.0, 15.0);
double aScale = 0.2;
double c = UxHwDoubleMixture(a, b, aScale);
printf("c = %lf\n", c);
return 0;
}