diff --git a/packages/squiggle-lang/benchmark/conversion_tests.ts b/packages/squiggle-lang/benchmark/conversion_tests.ts index 94a6475d..7cdd72cc 100644 --- a/packages/squiggle-lang/benchmark/conversion_tests.ts +++ b/packages/squiggle-lang/benchmark/conversion_tests.ts @@ -1,4 +1,4 @@ -import { distributions, generateFloat, generateFloatRange } from "./generators"; +import { distributions, generateInt, generateFloatRange } from "./generators"; import { test, expectEqual } from "./lib"; let checkDistributionSame = ( @@ -21,7 +21,7 @@ Object.entries(distributions).map(([key, generator]) => { checkDistributionSame(distribution, (d: string) => `mean(${d})`)); test(`cdf is the same for ${key} distribution under all distribution types`, () => { - let cdf_value = generateFloat(); + let cdf_value = generateInt(); checkDistributionSame( distribution, (d: string) => `cdf(${d}, ${cdf_value})` @@ -29,7 +29,7 @@ Object.entries(distributions).map(([key, generator]) => { }); test(`pdf is the same for ${key} distribution under all distribution types`, () => { - let pdf_value = generateFloat(); + let pdf_value = generateInt(); checkDistributionSame( distribution, (d: string) => `pdf(${d}, ${pdf_value})` diff --git a/packages/squiggle-lang/benchmark/generators.ts b/packages/squiggle-lang/benchmark/generators.ts index d07c359c..e3949e9b 100644 --- a/packages/squiggle-lang/benchmark/generators.ts +++ b/packages/squiggle-lang/benchmark/generators.ts @@ -1,38 +1,39 @@ export let generateFloatRange = (min: number, max: number): number => - Math.floor(Math.random() * (max - min) + min); + Math.random() * (max - min) + min; +export let generateIntRange = (min: number, max: number): number => + Math.floor(generateFloatRange(min, max)); -export let generateFloatMin = (min: number): number => - generateFloatRange(min, 100); +export let generateIntMin = (min: number): number => generateIntRange(min, 100); -export let generateFloat = (): number => generateFloatMin(-100); +export let generateInt = (): number => generateIntMin(-100); -let generatePositive = (): number => generateFloatMin(1); +let generatePositiveInt = (): number => generateIntMin(1); export let generateNormal = (): string => - `normal(${generateFloat()}, ${generatePositive()})`; + `normal(${generateInt()}, ${generatePositiveInt()})`; export let generateBeta = (): string => - `beta(${generatePositive()}, ${generatePositive()})`; + `beta(${generatePositiveInt()}, ${generatePositiveInt()})`; export let generateLognormal = (): string => - `lognormal(${generateFloat()}, ${generatePositive()})`; + `lognormal(${generateInt()}, ${generatePositiveInt()})`; export let generateExponential = (): string => - `exponential(${generatePositive()})`; + `exponential(${generatePositiveInt()})`; export let generateUniform = (): string => { - let a = generateFloat(); - let b = generateFloatMin(a + 1); + let a = generateInt(); + let b = generateIntMin(a + 1); return `uniform(${a}, ${b})`; }; export let generateCauchy = (): string => { - return `cauchy(${generateFloat()}, ${generatePositive()})`; + return `cauchy(${generateInt()}, ${generatePositiveInt()})`; }; export let generateTriangular = (): string => { - let a = generateFloat(); - let b = generateFloatMin(a + 1); - let c = generateFloatMin(b + 1); + let a = generateInt(); + let b = generateIntMin(a + 1); + let c = generateIntMin(b + 1); return `triangular(${a}, ${b}, ${c})`; };