Skip to main content

Nth Mode of a Distribution

Name​

UxHwDoubleNthMode, UxHwFloatNthMode — Return the nnth most-frequently occurring value of a distribution.

Synopsis​

#include <stddef.h>
#include <uxhw.h>

double UxHwDoubleNthMode(double value, size_t n);
float UxHwFloatNthMode(float value, size_t n);

Description​

The UxHwDoubleNthMode() function returns the nnth mode of the distribution associated with value, on architectures that associate distributional information with floating-point values. The nnth mode of a distribution in statistics, is defined as the nnth most frequently occurring value in the set distribution.

Parameters​

  • value — The distributional value to take the nth mode from.
  • n — The order of the mode.

Return values​

The UxHwDoubleNthMode() function returns the nth mode of the distribution associated with value. If there is no distribution associated with value, the function returns value. If n is greater than the number of modes of the distribution associated with value, the function returns NaN.

If value is NaN with no associated distribution, the function returns -NaN. See Handling of NaN.

Examples​

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

int
main(void)
{
double a = UxHwDoubleUniformDist(10.0, 20.0);
double secondMode = UxHwDoubleNthMode(a, 2);

printf("Second mode is %lf.\n", secondMode);

return 0;
}