Skip to main content

Chi-squared Distribution

Name

UxHwDoubleChiSquaredDist, UxHwFloatChiSquaredDist Create an χ2\chi^2 distribution.

Synopsis

#include <uxhw.h>

double UxHwDoubleChiSquaredDist(double k);
float UxHwFloatChiSquaredDist(float k);

Description

The UxHwDoubleChiSquaredDist() function, on architectures that associate distributional information with floating-point values, creates a χ2\chi^2 distribution with parameter k and associates it with its return value. The particle return value is the mean value of a χ2\chi^2 distribution with parameter k. The probability density function of the χ2\chi^2 distribution is

f(x;k)={1Γ(k/2)2kxk/21ex/2x0,0x<0.f(x;k)= \begin{cases} \frac{1}{\Gamma(k/2)2^k}x^{k/2-1}e^{-x/2} & x\ge 0, \\ 0 & x < 0. \end{cases}

Parameters

  • k The parameter (kk) of the χ2\chi^2 distribution.

Return Values

The UxHwDoubleChiSquaredDist() function returns the mean of samples of a χ2\chi^2 distribution with parameter k. If k <= 0, the function returns NaN.

  Examples

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

int
main(void)
{
double value = UxHwDoubleChiSquaredDist(1.0);
printf("value = %lf\n", value);

return 0;
}