function dataGenerator(lowNoise, highNoise, seed, flip, n, scaleData) {
let rand = random(seed);
const randNormal = d3.randomNormal.source(rand)(mu, sigma);
const start = 1;
let value = start;
const motion = fc
.randomGeometricBrownianMotion()
.mu(mu)
.sigma(sigma)
.period(1)
.steps(n + smoothing)
.random(randNormal)(start);
const sequence = movingAverage(motion, smoothing).slice(smoothing);
const scale = d3.scaleLinear().domain(d3.extent(sequence));
const baseSequence = sequence.map(scale);
rand = random(seed + 1);
let out = d3.range(n).map((i) => {
const base = baseSequence[i];
const noise = lowNoise * (1 - base) + highNoise * base;
return base + (rand() - 0.5) * noise;
});
if (scaleData) {
const scale2 = d3.scaleLinear().domain(d3.extent(out));
out = out.map(scale2);
}
if (flip) {
out = out.map((d) => 1 - d);
}
return out;
}