diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0d82643..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:00:54.297Z diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0dae4fe..3bc3576 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -29,6 +29,7 @@ Ognjen Jevremović Philipp Burckhardt Pranav Goswami Ricky Reusser +Robert Gislason Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Ryan Seal Seyyed Parsa Neshaei @@ -37,4 +38,3 @@ Stephannie Jiménez Gacha Yernar Yergaziyev orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu -Robert Gislason diff --git a/README.md b/README.md index bb7a0e3..2b091c1 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,11 @@ For more information on the project, filing bug reports and feature requests, an --- +## License + +See [LICENSE][stdlib-license]. + + ## Copyright Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. @@ -383,6 +388,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [esm-url]: https://github.com/stdlib-js/stats-base-dists-hypergeometric-ctor/tree/esm [branches-url]: https://github.com/stdlib-js/stats-base-dists-hypergeometric-ctor/blob/main/branches.md +[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-base-dists-hypergeometric-ctor/main/LICENSE + [hypergeometric-distribution]: https://en.wikipedia.org/wiki/Hypergeometric_distribution [cdf]: https://en.wikipedia.org/wiki/Cumulative_distribution_function diff --git a/dist/index.js b/dist/index.js index 45e5471..f213a6f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,29 +1,5 @@ +"use strict";var l=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var p=l(function(k,f){ +var o=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,g=require('@stdlib/utils-define-property/dist'),h=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),u=require('@stdlib/utils-define-nonenumerable-read-only-accessor/dist'),m=require('@stdlib/stats-base-dists-hypergeometric-kurtosis/dist'),c=require('@stdlib/stats-base-dists-hypergeometric-mean/dist'),w=require('@stdlib/stats-base-dists-hypergeometric-mode/dist'),v=require('@stdlib/stats-base-dists-hypergeometric-skewness/dist'),q=require('@stdlib/stats-base-dists-hypergeometric-stdev/dist'),y=require('@stdlib/stats-base-dists-hypergeometric-variance/dist'),d=require('@stdlib/stats-base-dists-hypergeometric-cdf/dist'),b=require('@stdlib/stats-base-dists-hypergeometric-logpmf/dist'),E=require('@stdlib/stats-base-dists-hypergeometric-pmf/dist'),V=require('@stdlib/stats-base-dists-hypergeometric-quantile/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function M(e){return d(e,this.N,this.K,this.n)}function R(e){return b(e,this.N,this.K,this.n)}function T(e){return E(e,this.N,this.K,this.n)}function z(e){return V(e,this.N,this.K,this.n)}function n(e,r,s){if(!(this instanceof n))return new n(e,r,s);if(!o(e))throw new TypeError(i('12R93',e));if(!o(r))throw new TypeError(i('12R94',r));if(!o(s))throw new TypeError(i('12R95',s));if(r>e)throw new RangeError(i('12RCw'));if(s>e)throw new RangeError(i('12RCx'));return g(this,"N",{configurable:!1,enumerable:!0,get:function(){return e},set:function(t){if(!o(t))throw new TypeError(i('12R96',t));if(r>t)throw new RangeError(i('12R97',r,t));if(s>t)throw new RangeError(i('12R97',s,t));e=t}}),g(this,"K",{configurable:!1,enumerable:!0,get:function(){return r},set:function(t){if(!o(t))throw new TypeError(i('12R96',t));if(t>e)throw new RangeError(i('12R98',e,t));r=t}}),g(this,"n",{configurable:!1,enumerable:!0,get:function(){return s},set:function(t){if(!o(t))throw new TypeError(i('12R96',t));if(t>e)throw new RangeError(i('12R98',e,t));s=t}}),this;}u(n.prototype,"kurtosis",function(){return m(this.N,this.K,this.n)});u(n.prototype,"mean",function(){return c(this.N,this.K,this.n)});u(n.prototype,"mode",function(){return w(this.N,this.K,this.n)});u(n.prototype,"skewness",function(){return v(this.N,this.K,this.n)});u(n.prototype,"stdev",function(){return q(this.N,this.K,this.n)});u(n.prototype,"variance",function(){return y(this.N,this.K,this.n)});h(n.prototype,"cdf",M);h(n.prototype,"logpmf",R);h(n.prototype,"pmf",T);h(n.prototype,"quantile",z);f.exports=n +});var N=p();module.exports=N; /** @license Apache-2.0 */ - -'use strict'; - -/** -* Hypergeometric distribution constructor. -* -* @module @stdlib/stats-base-dists-hypergeometric-ctor -* -* @example -* var Hypergeometric = require( '@stdlib/stats-base-dists-hypergeometric-ctor' ); -* -* var hypergeometric = new Hypergeometric( 40, 10, 8 ); -* -* var y = hypergeometric.cdf( 2.8 ); -* // returns ~0.688 -* -* var mode = hypergeometric.mode; -* // returns 2.0 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; +//# sourceMappingURL=index.js.map diff --git a/dist/main.js b/dist/main.js deleted file mode 100644 index e913a6d..0000000 --- a/dist/main.js +++ /dev/null @@ -1,370 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var defineProperty = require( '@stdlib/utils-define-property' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var kurtosis = require( '@stdlib/stats-base-dists-hypergeometric-kurtosis' ); -var mean = require( '@stdlib/stats-base-dists-hypergeometric-mean' ); -var mode = require( '@stdlib/stats-base-dists-hypergeometric-mode' ); -var skewness = require( '@stdlib/stats-base-dists-hypergeometric-skewness' ); -var stdev = require( '@stdlib/stats-base-dists-hypergeometric-stdev' ); -var variance = require( '@stdlib/stats-base-dists-hypergeometric-variance' ); -var cdf = require( '@stdlib/stats-base-dists-hypergeometric-cdf' ); -var logpmf = require( '@stdlib/stats-base-dists-hypergeometric-logpmf' ); -var pmf = require( '@stdlib/stats-base-dists-hypergeometric-pmf' ); -var quantile = require( '@stdlib/stats-base-dists-hypergeometric-quantile' ); -var format = require( '@stdlib/string-format' ); - - -// FUNCTIONS // - -/** -* Evaluates the cumulative distribution function (CDF). -* -* @private -* @param {number} x - input value -* @returns {Probability} evaluated CDF -*/ -function hypergeometricCDF( x ) { - return cdf( x, this.N, this.K, this.n ); -} - -/** -* Evaluates the natural logarithm of the probability mass function (PMF). -* -* @private -* @param {number} x - input value -* @returns {Probability} evaluated PMF -*/ -function hypergeometricLogPMF( x ) { - return logpmf( x, this.N, this.K, this.n ); -} - -/** -* Evaluates the probability mass function (PMF). -* -* @private -* @param {number} x - input value -* @returns {Probability} evaluated PMF -*/ -function hypergeometricPMF( x ) { - return pmf( x, this.N, this.K, this.n ); -} - -/** -* Evaluates the quantile function. -* -* @private -* @param {Probability} p - input probability -* @returns {NonNegativeInteger} evaluated quantile function -*/ -function hypergeometricQuantile( p ) { - return quantile( p, this.N, this.K, this.n ); -} - - -// MAIN // - -/** -* Hypergeometric distribution constructor. -* -* @constructor -* @param {NonNegativeInteger} N - population size -* @param {NonNegativeInteger} K - subpopulation size -* @param {NonNegativeInteger} n - number of draws -* @throws {TypeError} `N` must be a nonnegative integer -* @throws {TypeError} `K` must be a nonnegative integer -* @throws {TypeError} `n` must be a nonnegative integer -* @throws {RangeError} `K` must not exceed `N` -* @throws {RangeError} `n` must not exceed `N` -* @returns {Hypergeometric} distribution instance -* -* @example -* var hypergeometric = new Hypergeometric( 10, 5, 7 ); -* -* var y = hypergeometric.cdf( 0.8 ); -* // returns 0.0 -* -* var v = hypergeometric.mode; -* // returns 4.0 -*/ -function Hypergeometric( N, K, n ) { - if ( !(this instanceof Hypergeometric) ) { - return new Hypergeometric( N, K, n ); - } - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. Population size must be a nonnegative integer. Value: `%s`.', N ) ); - } - if ( !isNonNegativeInteger( K ) ) { - throw new TypeError( format( 'invalid argument. Subpopulation size must be a nonnegative integer. Value: `%s`.', K ) ); - } - if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( format( 'invalid argument. Number of draws must be a nonnegative integer. Value: `%s`.', n ) ); - } - if ( K > N ) { - throw new RangeError( 'invalid arguments. Subpopulation size must be less than or equal to the population size.' ); - } - if ( n > N ) { - throw new RangeError( 'invalid arguments. Number of draws must be less than or equal to the population size.' ); - } - defineProperty( this, 'N', { - 'configurable': false, - 'enumerable': true, - 'get': function get() { - return N; - }, - 'set': function set( value ) { - if ( !isNonNegativeInteger( value ) ) { - throw new TypeError( format( 'invalid assignment. Must be a nonnegative integer. Value: `%s`.', value ) ); - } - if ( K > value ) { - throw new RangeError( format( 'invalid assignment. Must be larger than or equal to %u. Value: `%u`.', K, value ) ); - } - if ( n > value ) { - throw new RangeError( format( 'invalid assignment. Must be larger than or equal to %u. Value: `%u`.', n, value ) ); - } - N = value; - } - }); - defineProperty( this, 'K', { - 'configurable': false, - 'enumerable': true, - 'get': function get() { - return K; - }, - 'set': function set( value ) { - if ( !isNonNegativeInteger( value ) ) { - throw new TypeError( format( 'invalid assignment. Must be a nonnegative integer. Value: `%s`.', value ) ); - } - if ( value > N ) { - throw new RangeError( format( 'invalid assignment. Must be less than or equal to %u. Value: `%u`.', N, value ) ); - } - K = value; - } - }); - defineProperty( this, 'n', { - 'configurable': false, - 'enumerable': true, - 'get': function get() { - return n; - }, - 'set': function set( value ) { - if ( !isNonNegativeInteger( value ) ) { - throw new TypeError( format( 'invalid assignment. Must be a nonnegative integer. Value: `%s`.', value ) ); - } - if ( value > N ) { - throw new RangeError( format( 'invalid assignment. Must be less than or equal to %u. Value: `%u`.', N, value ) ); - } - n = value; - } - }); - return this; -} - -/** -* Hypergeometric distribution excess kurtosis. -* -* @name kurtosis -* @memberof Hypergeometric.prototype -* @type {number} -* @see [kurtosis]{@link https://en.wikipedia.org/wiki/Kurtosis} -* -* @example -* var hypergeometric = new Hypergeometric( 20, 15, 5 ); -* -* var v = hypergeometric.kurtosis; -* // returns ~-0.276 -*/ -setReadOnlyAccessor( Hypergeometric.prototype, 'kurtosis', function get() { - return kurtosis( this.N, this.K, this.n ); -}); - -/** -* Hypergeometric distribution expected value. -* -* @name mean -* @memberof Hypergeometric.prototype -* @type {number} -* @see [expected value]{@link https://en.wikipedia.org/wiki/Expected_value} -* -* @example -* var hypergeometric = new Hypergeometric( 20, 15, 5 ); -* -* var v = hypergeometric.mean; -* // returns 3.75 -*/ -setReadOnlyAccessor( Hypergeometric.prototype, 'mean', function get() { - return mean( this.N, this.K, this.n ); -}); - -/** -* Hypergeometric distribution mode. -* -* @name mode -* @memberof Hypergeometric.prototype -* @type {NonNegativeInteger} -* @see [mode]{@link https://en.wikipedia.org/wiki/Mode_%28statistics%29} -* -* @example -* var hypergeometric = new Hypergeometric( 20, 15, 5 ); -* -* var v = hypergeometric.mode; -* // returns 4.0 -*/ -setReadOnlyAccessor( Hypergeometric.prototype, 'mode', function get() { - return mode( this.N, this.K, this.n ); -}); - -/** -* Hypergeometric distribution skewness. -* -* @name skewness -* @memberof Hypergeometric.prototype -* @type {number} -* @see [skewness]{@link https://en.wikipedia.org/wiki/Skewness} -* -* @example -* var hypergeometric = new Hypergeometric( 20, 15, 5 ); -* -* var v = hypergeometric.skewness; -* // returns ~-0.323 -*/ -setReadOnlyAccessor( Hypergeometric.prototype, 'skewness', function get() { - return skewness( this.N, this.K, this.n ); -}); - -/** -* Hypergeometric distribution standard deviation. -* -* @name stdev -* @memberof Hypergeometric.prototype -* @type {NonNegativeNumber} -* @see [standard deviation]{@link https://en.wikipedia.org/wiki/Standard_deviation} -* -* @example -* var hypergeometric = new Hypergeometric( 20, 15, 5 ); -* -* var v = hypergeometric.stdev; -* // returns ~0.86 -*/ -setReadOnlyAccessor( Hypergeometric.prototype, 'stdev', function get() { - return stdev( this.N, this.K, this.n ); -}); - -/** -* Hypergeometric distribution variance. -* -* @name variance -* @memberof Hypergeometric.prototype -* @type {NonNegativeNumber} -* @see [variance]{@link https://en.wikipedia.org/wiki/Variance} -* -* @example -* var hypergeometric = new Hypergeometric( 20, 15, 5 ); -* -* var v = hypergeometric.variance; -* // returns ~0.74 -*/ -setReadOnlyAccessor( Hypergeometric.prototype, 'variance', function get() { - return variance( this.N, this.K, this.n ); -}); - -/** -* Evaluates the cumulative distribution function (CDF). -* -* @name cdf -* @memberof Hypergeometric.prototype -* @type {Function} -* @param {number} x - input value -* @returns {Probability} evaluated CDF -* @see [cdf]{@link https://en.wikipedia.org/wiki/Cumulative_distribution_function} -* -* @example -* var hypergeometric = new Hypergeometric( 8, 2, 4 ); -* -* var v = hypergeometric.cdf( 0.5 ); -* // returns ~0.214 -*/ -setReadOnly( Hypergeometric.prototype, 'cdf', hypergeometricCDF ); - -/** -* Evaluates the natural logarithm of the probability density function (PMF). -* -* @name logpmf -* @memberof Hypergeometric.prototype -* @type {Function} -* @param {number} x - input value -* @returns {number} evaluated logPMF -* @see [pmf]{@link https://en.wikipedia.org/wiki/Probability_mass_function} -* -* @example -* var hypergeometric = new Hypergeometric( 8, 2, 4 ); -* -* var v = hypergeometric.logpmf( 2.0 ); -* // returns ~-1.54 -*/ -setReadOnly( Hypergeometric.prototype, 'logpmf', hypergeometricLogPMF ); - -/** -* Evaluates the probability density function (PMF). -* -* @name pmf -* @memberof Hypergeometric.prototype -* @type {Function} -* @param {number} x - input value -* @returns {number} evaluated PMF -* @see [pmf]{@link https://en.wikipedia.org/wiki/Probability_mass_function} -* -* @example -* var hypergeometric = new Hypergeometric( 8, 2, 4 ); -* -* var v = hypergeometric.pmf( 2.0 ); -* // returns ~0.214 -*/ -setReadOnly( Hypergeometric.prototype, 'pmf', hypergeometricPMF ); - -/** -* Evaluates the quantile function. -* -* @name quantile -* @memberof Hypergeometric.prototype -* @type {Function} -* @param {Probability} p - input probability -* @returns {NonNegativeInteger} evaluated quantile function -* @see [quantile function]{@link https://en.wikipedia.org/wiki/Quantile_function} -* -* @example -* var hypergeometric = new Hypergeometric( 8, 2, 4 ); -* -* var v = hypergeometric.quantile( 0.8 ); -* // returns 2 -*/ -setReadOnly( Hypergeometric.prototype, 'quantile', hypergeometricQuantile ); - - -// EXPORTS // - -module.exports = Hypergeometric; diff --git a/docs/types/test.ts b/docs/types/test.ts index 02fe8ff..cdd72e0 100644 --- a/docs/types/test.ts +++ b/docs/types/test.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions */ import Hypergeometric = require( './index' ); diff --git a/package.json b/package.json index 8a408c7..aec6731 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "devDependencies": { "@stdlib/assert-has-own-property": "^0.1.1", "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/bench": "^0.1.0", + "@stdlib/bench": "^0.2.0", "@stdlib/constants-float64-eps": "^0.1.1", "@stdlib/math-base-assert-is-nan": "^0.1.1", "@stdlib/math-base-special-ceil": "^0.1.1",