Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return max - (max - mode)*Math.sqrt(2*(1-u))
}
}
// Source:
// https://en.wikipedia.org/wiki/Beta_distribution#Transformations
function PERT(min, max, mode = (min + max)/2, lambda = 4) {
const width = max - min
const a = 1 + lambda * ((mode - min)/width)
const b = 1 + lambda * ((max - mode)/width)
const p = jStat.beta.sample(a, b)
return min + p*width
}
export const Distributions = {
beta: jStat.beta.sample,
centralF: jStat.centralF.sample,
cauchy: jStat.cauchy.sample,
chisquare: jStat.chisquare.sample,
exponential: jStat.exponential.sample,
invgamma: jStat.invgamma.sample,
lognormal: jStat.lognormal.sample,
normal: jStat.normal.sample,
studentt: jStat.studentt.sample,
weibull: jStat.weibull.sample,
uniform: jStat.uniform.sample,
gamma: jStat.gamma.sample,
triangular,
doubleTriangular,
PERT,
bernoulli: bernoulli,
if: bernoulli,
function PERT(min, max, mode = (min + max)/2, lambda = 4) {
const width = max - min
const a = 1 + lambda * ((mode - min)/width)
const b = 1 + lambda * ((max - mode)/width)
const p = jStat.beta.sample(a, b)
return min + p*width
}
import math from 'mathjs'
import {jStat} from 'jstat'
var Finance = require('financejs')
const finance = new Finance()
const jStatDistributions = {
beta: jStat.beta.sample,
centralF: jStat.centralF.sample,
cauchy: jStat.cauchy.sample,
chisquare: jStat.chisquare.sample,
exponential: jStat.exponential.sample,
invgamma: jStat.invgamma.sample,
lognormal: jStat.lognormal.sample,
normal: jStat.normal.sample,
studentt: jStat.studentt.sample,
weibull: jStat.weibull.sample,
uniform: jStat.uniform.sample,
gamma: jStat.gamma.sample
}
const financeFunctions = {
PV: finance.PV,
FV: finance.FV,