'use strict';

// FUNCTIONS //

var ln = require( '@stdlib/math/base/special/ln' );
var isnan = require( '@stdlib/math/base/utils/is-nan' );


// QUANTILE //

/**
* Evaluates the quantile function for a logistic distribution with location parameter `mu` and scale parameter `s` at a probability `p`.
*
* @param {Probability} p - input value
* @param {number} mu - location parameter
* @param {NonNegativeNumber} s - scale parameter
* @returns {number} evaluated quantile function
*
* @example
* var y = quantile( 0.8, 0.0, 1.0 );
* // returns ~1.386
* @example
* var y = quantile( 0.5, 4.0, 2.0 );
* // returns 4
* @example
* var y = quantile( 1.1, 0.0, 1.0 );
* // returns NaN
* @example
* var y = quantile( -0.2, 0.0, 1.0 );
* // returns NaN
* @example
* var y = quantile( NaN, 0.0, 1.0 );
* // returns NaN
* @example
* var y = quantile( 0.0, NaN, 1.0 );
* // returns NaN
* @example
* var y = quantile( 0.0, 0.0, NaN );
* // returns NaN
* @example
* // Negative scale parameter:
* var y = quantile( 0.5, 0.0, -1.0 );
* // returns NaN
*/
function quantile( p, mu, s ) {
	if ( isnan( p ) || p < 0.0 || p > 1.0 ) {
		return NaN;
	}
	if ( s < 0.0 ) {
		return NaN;
	}
	if ( s === 0.0 ) {
		return mu;
	}
	return mu + s * ln( p / ( 1.0 - p ) );
} // end FUNCTION quantile()


// EXPORTS //

module.exports = quantile;

'use strict';

// FUNCTIONS //

var isnan = require( '@stdlib/math/base/utils/is-nan' );
var ln = require( '@stdlib/math/base/special/ln' );


// QUANTILE //

/**
* Evaluates the quantile function for a logistic distribution with location parameter `mu` and scale parameter `s` at a probability `p`.
*
* @param {Probability} p - input value
* @param {number} mu - location parameter
* @param {NonNegativeNumber} s - scale parameter
* @returns {number} evaluated quantile function
*
* @example
* var y = quantile( 0.8, 0.0, 1.0 );
* // returns ~1.386
* @example
* var y = quantile( 0.5, 4.0, 2.0 );
* // returns 4
* @example
* var y = quantile( 1.1, 0.0, 1.0 );
* // returns NaN
* @example
* var y = quantile( -0.2, 0.0, 1.0 );
* // returns NaN
* @example
* var y = quantile( NaN, 0.0, 1.0 );
* // returns NaN
* @example
* var y = quantile( 0.0, NaN, 1.0 );
* // returns NaN
* @example
* var y = quantile( 0.0, 0.0, NaN );
* // returns NaN
* @example
* // Negative scale parameter:
* var y = quantile( 0.5, 0.0, -1.0 );
* // returns NaN
*/
function quantile( p, mu, s ) {
	if (
		isnan( mu ) ||
		isnan( s ) ||
		s < 0.0
	) {
		return NaN;
	}
	if ( isnan( p ) || p < 0.0 || p > 1.0 ) {
		return NaN;
	}
	if ( s === 0.0 ) {
		return mu;
	}
	return mu + s * ln( p / ( 1.0 - p ) );
} // end FUNCTION quantile()


// EXPORTS //

module.exports = quantile;

Add argument checks