@stdlib/stats-base-dists-arcsine-median
v0.3.1
Published
Arcsine distribution median.
Readme
Median
The median for an arcsine random variable is
where a is the minimum support and b is the maximum support.
Installation
npm install @stdlib/stats-base-dists-arcsine-medianUsage
var median = require( '@stdlib/stats-base-dists-arcsine-median' );median( a, b )
Returns the median of an arcsine distribution with parameters a (minimum support) and b (maximum support).
var v = median( 0.0, 1.0 );
// returns 0.5
v = median( 4.0, 12.0 );
// returns 8.0
v = median( 2.0, 8.0 );
// returns 5.0If provided NaN as any argument, the function returns NaN.
var v = median( NaN, 2.0 );
// returns NaN
v = median( 2.0, NaN );
// returns NaNIf provided a >= b, the function returns NaN.
var y = median( 3.0, 2.0 );
// returns NaN
y = median( 3.0, 3.0 );
// returns NaNExamples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var median = require( '@stdlib/stats-base-dists-arcsine-median' );
var opts = {
'dtype': 'float64'
};
var a = uniform( 25, 0.0, 10.0, opts );
var b = uniform( a.length, 10.0, 20.0, opts );
logEachMap( 'a: %0.4f, b: %0.4f, Median(X;a,b): %0.4f', a, b, median );C APIs
Usage
#include "stdlib/stats/base/dists/arcsine/median.h"stdlib_base_dists_arcsine_median( a, b )
Returns the median of an arcsine distribution.
double out = stdlib_base_dists_arcsine_median( 0.0, 1.0 );
// returns 0.5The function accepts the following arguments:
- a:
[in] doubleminimum support. - b:
[in] doublemaximum support.
double stdlib_base_dists_arcsine_median( const double a, const double b );Examples
#include "stdlib/stats/base/dists/arcsine/median.h"
#include <stdlib.h>
#include <stdio.h>
static double random_uniform( const double min, const double max ) {
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
return min + ( v*(max-min) );
}
int main( void ) {
double a;
double b;
double y;
int i;
for ( i = 0; i < 10; i++ ) {
a = random_uniform( 0.0, 10.0 );
b = random_uniform( a, a+10.0 );
y = stdlib_base_dists_arcsine_median( a, b );
printf( "a: %lf, b: %lf, Median(X;a,b): %lf\n", a, b, y );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
