Published
Edited
May 19, 2021
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
HDRando(seed, 0) // seed and index location on the stream from seed location (loop to generate x trials)
Insert cell
seed = 10
// need to confirm how large this number can be
Insert cell
trials = 10000
Insert cell
Insert cell
uni = Array(trials)
.fill()
//.map((_, i) => HDRando(seed, i))
.map((_, i) => HDRando2(1, seed, 0, 0, i)) // updated hdr supports 5 inputs needed for sipmath standard 3.0
Insert cell
Insert cell
Insert cell
histogram(
Array(trials)
.fill()
.map((_, i) => HDRando2(1, seed, 0, 0, i)),
600,
300,
"Random values array 1",
30
)
Insert cell
md`### Code for HDR split into two functions`
Insert cell
Insert cell
function HDRando2(entityID, varId, option1, option2, PM_Index) {
// supports 4 variables for sip 3.0 standard
const largePrime = 4294967296; // there are a lot of primes. ?? Need to find out when to change them
// Do we need this in js? is there a modulo?
function MOD(n, m) {
var remain = n % m;
return Math.floor(remain >= 0 ? remain : remain + m);
}
let randi =
(MOD(
(MOD(
MOD(
999999999999989,
MOD(
PM_Index * 2499997 +
varId * 1800451 +
entityID * 2000371 +
option1 * 1796777 +
option2 * 2299603,
7450589
) *
4658 +
7450581
) * 383,
99991
) *
7440893 +
MOD(
MOD(
999999999999989,
MOD(
PM_Index * 2246527 +
varId * 2399993 +
entityID * 2100869 +
option1 * 1918303 +
option2 * 1624729,
7450987
) *
7580 +
7560584
) * 17669,
7440893
)) *
1343,
largePrime
) +
0.5) /
largePrime;

return randi;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more