mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-23 04:47:24 +08:00
add npm gaussian
This commit is contained in:
14
gaussian/gaussian-tests.ts
Normal file
14
gaussian/gaussian-tests.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
const d = gaussian(0, 1);
|
||||
const _ = d.mean !== d.variance;
|
||||
const __ = d.mean * d.standardDeviation;
|
||||
d.pdf(-2);
|
||||
d.cdf(-1.28155);
|
||||
d.ppf(0.1);
|
||||
|
||||
gaussian(0, 1).mul(gaussian(0, 1));
|
||||
gaussian(1, 1).mul(2);
|
||||
gaussian(1, 1).add(gaussian(1, 2));
|
||||
gaussian(1, 1).sub(gaussian(1, 2));
|
||||
gaussian(1, 1).div(gaussian(1, 2));
|
||||
gaussian(1, 1).div(2);
|
||||
gaussian(1, 1).scale(2);
|
||||
65
gaussian/index.d.ts
vendored
Normal file
65
gaussian/index.d.ts
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// Type definitions for gaussian 1.1.0
|
||||
// Project: https://github.com/errcw/gaussian
|
||||
// Definitions by: Scott Cooper <https://github.com/scttcper>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function gaussian(mean: number, variance: number): gaussian.Gaussian;
|
||||
|
||||
export = gaussian;
|
||||
export as namespace gaussian;
|
||||
|
||||
declare namespace gaussian {
|
||||
export interface Gaussian {
|
||||
/**
|
||||
* the mean (μ) of the distribution
|
||||
*/
|
||||
mean: number;
|
||||
/**
|
||||
* the variance (σ^2) of the distribution
|
||||
*/
|
||||
variance: number;
|
||||
/**
|
||||
* the standard deviation (σ) of the distribution
|
||||
*/
|
||||
standardDeviation: number;
|
||||
/**
|
||||
* the probability density function, which describes the
|
||||
* probability of a random variable taking on the value x
|
||||
*/
|
||||
pdf(x: number): number;
|
||||
/**
|
||||
* the cumulative distribution function, which describes the
|
||||
* probability of a random variable falling in the interval (−∞, x]
|
||||
*/
|
||||
cdf(x: number): number;
|
||||
/**
|
||||
* the percent point function, the inverse of cdf
|
||||
*/
|
||||
ppf(x: number): number;
|
||||
/**
|
||||
* returns the product distribution of this and the given
|
||||
* distribution; equivalent to scale(d) when d is a constant
|
||||
*/
|
||||
mul(x: number | Gaussian): number;
|
||||
/**
|
||||
* returns the quotient distribution of this and the given
|
||||
* distribution; equivalent to scale(1/d) when d is a constant
|
||||
*/
|
||||
div(x: number | Gaussian): number;
|
||||
/**
|
||||
* returns the result of adding this and the given
|
||||
* distribution's means and variances
|
||||
*/
|
||||
add(x: Gaussian): number;
|
||||
/**
|
||||
* returns the result of subtracting this and the given
|
||||
* distribution's means and variances
|
||||
*/
|
||||
sub(x: Gaussian): number;
|
||||
/**
|
||||
* returns the result of scaling this distribution by the
|
||||
* given constant
|
||||
*/
|
||||
scale(x: number): number;
|
||||
}
|
||||
}
|
||||
19
gaussian/tsconfig.json
Normal file
19
gaussian/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gaussian-tests.ts"
|
||||
]
|
||||
}
|
||||
1
gaussian/tslint.json
Normal file
1
gaussian/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user