2022-04-26 20:38:17 +00:00
|
|
|
export let generateFloatRange = (min: number, max: number): number =>
|
|
|
|
Math.floor(Math.random() * (max - min) + min);
|
2022-04-26 18:26:02 +00:00
|
|
|
|
2022-04-26 20:38:17 +00:00
|
|
|
export let generateFloatMin = (min: number): number =>
|
|
|
|
generateFloatRange(min, 100);
|
|
|
|
|
|
|
|
export let generateFloat = (): number => generateFloatMin(-100);
|
|
|
|
|
|
|
|
let generatePositive = (): number => generateFloatMin(1);
|
2022-04-26 18:26:02 +00:00
|
|
|
|
|
|
|
export let generateNormal = (): string =>
|
|
|
|
`normal(${generateFloat()}, ${generatePositive()})`;
|
|
|
|
|
|
|
|
export let generateBeta = (): string =>
|
|
|
|
`beta(${generatePositive()}, ${generatePositive()})`;
|
|
|
|
|
|
|
|
export let generateLognormal = (): string =>
|
|
|
|
`lognormal(${generateFloat()}, ${generatePositive()})`;
|
2022-04-26 20:05:16 +00:00
|
|
|
|
|
|
|
export let generateExponential = (): string =>
|
|
|
|
`exponential(${generatePositive()})`;
|
|
|
|
|
|
|
|
export let generateUniform = (): string => {
|
2022-04-26 20:38:17 +00:00
|
|
|
let a = generateFloat();
|
|
|
|
let b = generateFloatMin(a + 1);
|
|
|
|
return `uniform(${a}, ${b})`;
|
|
|
|
};
|
2022-04-26 20:05:16 +00:00
|
|
|
export let generateCauchy = (): string => {
|
2022-04-26 20:38:17 +00:00
|
|
|
return `cauchy(${generateFloat()}, ${generatePositive()})`;
|
|
|
|
};
|
2022-04-26 20:05:16 +00:00
|
|
|
|
|
|
|
export let generateTriangular = (): string => {
|
2022-04-26 20:38:17 +00:00
|
|
|
let a = generateFloat();
|
|
|
|
let b = generateFloatMin(a + 1);
|
|
|
|
let c = generateFloatMin(b + 1);
|
|
|
|
return `triangular(${a}, ${b}, ${c})`;
|
|
|
|
};
|
|
|
|
|
|
|
|
export let distributions: { [key: string]: () => string } = {
|
|
|
|
normal: generateNormal,
|
|
|
|
beta: generateBeta,
|
|
|
|
lognormal: generateLognormal,
|
|
|
|
exponential: generateExponential,
|
|
|
|
triangular: generateTriangular,
|
2022-04-26 20:05:16 +00:00
|
|
|
cauchy: generateCauchy,
|
2022-04-26 20:38:17 +00:00
|
|
|
uniform: generateUniform,
|
|
|
|
};
|