Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private generateIdentifier(): string {
const length = Math.ceil(jStat.gamma.sample(ID_GAMMA_SHAPE, ID_GAMMA_SCALE)) as number;
let identifier = ALPHA_CHARSET[Math.floor(Math.random() * ALPHA_CHARSET.length)];
for (let i = 1; i < length; i += 1) {
identifier += ALPHA_NUMERIC_CHARSET[Math.floor(Math.random() * ALPHA_NUMERIC_CHARSET.length)];
}
if (keywords.has(identifier.toLowerCase())) {
return this.generateIdentifier();
}
return identifier;
}
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,
NPV: finance.NPV,
//IRR: finance.IRR, Too slow.
PP: finance.PP,
ROI: finance.ROI,
AM: finance.AM,
PI: finance.PI,
DF: finance.DF,
CI: finance.CI,
CAGR: finance.CAGR,
LR: finance.LR,
R72: finance.R72,
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,
test: bernoulli,
binomial: binomial,
poisson: poisson,
negBinomial: negBinomial
}
private generateString(): string {
const length = jStat.gamma.sample(STRING_GAMMA_SHAPE, STRING_GAMMA_SCALE) as number;
return `"${this.generateRandomString(length)}"`;
}