@stdlib/math-base-special-logitf
v0.1.1
Published
Logit function for a single-precision floating-point number.
Readme
logitf
Compute the logit function for a single-precision floating-point number.
The logit function is defined as the logarithm of the odds p / (1-p); i.e.,
The logit function is the inverse of the standard logistic function, sometimes also called the sigmoid function.
Installation
npm install @stdlib/math-base-special-logitfUsage
var logitf = require( '@stdlib/math-base-special-logitf' );logitf( p )
Computes the logit function for a single-precision floating-point number.
var v = logitf( 0.2 );
// returns ~-1.386
v = logitf( 0.9 );
// returns ~2.197If p < 0 or p > 1, the function returns NaN.
var v = logitf( 1.3 );
// returns NaN
v = logitf( -0.2 );
// returns NaNExamples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var logitf = require( '@stdlib/math-base-special-logitf' );
var opts = {
'dtype': 'float32'
};
var p = uniform( 100, 0.0, 1.0, opts );
logEachMap( 'logitf(%0.4f) = %0.4f', p, logitf );C APIs
Usage
#include "stdlib/math/base/special/logitf.h"stdlib_base_logitf( p )
Computes the logit function for a single-precision floating-point number.
float out = stdlib_base_logitf( 0.2f );
// returns ~-1.386f
out = stdlib_base_logitf( 0.9f );
// returns ~2.197fThe function accepts the following arguments:
- p:
[in] floatinput value.
float stdlib_base_logitf( const float p );Examples
#include "stdlib/math/base/special/logitf.h"
#include <stdlib.h>
#include <stdio.h>
int main( void ) {
float x;
float v;
int i;
for ( i = 0; i < 100; i++ ) {
x = (float)rand() / (float)RAND_MAX;
v = stdlib_base_logitf( x );
printf( "logitf(%f) = %f\n", x, v );
}
}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.
