Compute a one-parameter Box-Cox transformation for single-precision floating-point number.
The one-parameter Box-Cox transformation is defined as
var boxcoxf = require( '@stdlib/math/base/special/boxcoxf' );Computes a one-parameter Box-Cox transformation for a single-precision floating-point number.
var v = boxcoxf( 1.0, 2.5 );
// returns 0.0
v = boxcoxf( 4.0, 2.5 );
// returns ~12.4
v = boxcoxf( 10.0, 2.5 );
// returns ~126.0911
v = boxcoxf( 2.0, 0.0 );
// returns ~0.6931
v = boxcoxf( -1.0, 2.5 );
// returns NaN
v = boxcoxf( 0.0, -1.0 );
// returns -Infinityvar incrspace = require( '@stdlib/array/base/incrspace' );
var boxcoxf = require( '@stdlib/math/base/special/boxcoxf' );
var x = incrspace( -1.0, 10.0, 1.0 );
var l = incrspace( -0.5, 5.0, 0.5 );
var b;
var i;
var j;
for ( i = 0; i < x.length; i++ ) {
for ( j = 0; j < l.length; j++ ) {
b = boxcoxf( x[ i ], l[ j ] );
console.log( 'boxcoxf(%d, %d) = %d', x[ i ], l[ j ], b );
}
}#include "stdlib/math/base/special/boxcoxf.h"Computes a one-parameter Box-Cox transformation for a single-precision floating-point number.
float out = stdlib_base_boxcoxf( 1.0f, 2.5f );
// returns 0.0f
out = stdlib_base_boxcoxf( 4.0f, 2.5f );
// returns ~12.4fThe function accepts the following arguments:
- x:
[in] floatinput value. - lambda:
[in] floatpower parameter.
float stdlib_base_boxcoxf( const float x, const float lambda );#include "stdlib/math/base/special/boxcoxf.h"
#include <stdio.h>
int main( void ) {
const float x[] = { -1.0f, 10.0f, 1.0f };
const float y[] = { -0.5f, 5.0f, 0.5f };
float out;
int i;
int j;
for ( i = 0; i < 3; i++ ) {
for ( j = 0; j < 3; j++ ) {
out = stdlib_base_boxcoxf( x[ i ], y[ j ] );
printf( "x: %f, y: %f, out: %f\n", x[ i ], y[ j ], out );
}
}
}- Box, G. E. P., and D. R. Cox. 1964. "An Analysis of Transformations." Journal of the Royal Statistical Society. Series B (Methodological) 26 (2). [Royal Statistical Society, Wiley]: 211–52. http://www.jstor.org/stable/2984418.
@stdlib/math/base/special/boxcox: compute a one-parameter Box-Cox transformation.@stdlib/math/base/special/boxcoxinv: compute the inverse of a one-parameter Box-Cox transformation.@stdlib/math/base/special/boxcox1p: compute a one-parameter Box-Cox transformation of 1+x.@stdlib/math/base/special/boxcox1pinv: compute the inverse of a one-parameter Box-Cox transformation for 1+x.