Nth Centralized Moment of a Distribution
Name
UxHwDoubleNthMoment, UxHwFloatNthMoment — Return the nth centralized moment of a distribution.
Synopsis
#include <stddef.h>
#include <uxhw.h>
double UxHwDoubleNthMoment(double value, size_t n);
float UxHwFloatNthMoment(float value, size_t n);
Description
The UxHwDoubleNthMoment() function returns the th centralized moment of the distribution associated with value, on architectures that associate distributional information with floating-point values.
The th centralized moment of a distribution, in statistics is given by , where is the mean of the distribution and is the order of the moment.
The second centralized moment of a distribution is its variance, which is the square of its standard deviation ().
Because the first centralized moment of a distribution is by definition zero, for n equal to one the UxHwDoubleNthMoment() function returns the mean value of the distribution associated with value.
Parameters
value— The distributional value to calculate the centralised moment from.n— The order of the centralized moment.
Return Values
The UxHwDoubleNthMoment() function returns the th centralized moment of the distribution value, if n != 1.
The UxHwDoubleNthMoment() function returns the mean value of the distribution value, if n == 1.
If n == 0, the function returns 1.
If there is no distribution associated with value and n == 1, the function returns value.
If there is no distribution associated with value and n > 1, the function returns 0.
✏️ Examples
#include <stddef.h>
#include <stdio.h>
#include <uxhw.h>
int
main(void)
{
double a = UxHwDoubleUniformDist(10.0, 20.0);
double secondMoment = UxHwDoubleNthMoment(a, 2);
double meanValue = UxHwDoubleNthMoment(a, 1);
printf("Second centralized moment is %lf\n", secondMoment);
printf("Mean value is %lf\n", meanValue);
return 0;
}