Public
Edited
Jul 11, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof asymptote_upper2 = Inputs.range([peak, 1], {label: "Peakedness 2"})
Insert cell
Insert cell
Insert cell
data = {
const arr = new Array(T);
const arr2 = new Array(T);
/*
for(let t = 0; t < T; t++) {
arr[t] = {
x: t,
//y: asymptote * logistic(t, rate, timing) * observations[0].y / (asymptote * logistic(observations[0].x, rate, timing))
y: asymptote * logistic(t, rate, timing)
};
}
*/

const tstar = observations[0].x;
arr[tstar] = { x: tstar, y: observations[0].y, y2: observations[0].y };
for(let t = tstar - 1; t >= 0; t--) {
arr[t] = {
x: t,
y: arr[t + 1].y - logistic_rate(arr[t + 1].y, rate, asymptote_lower, asymptote_upper)
};
arr[t].y2 = arr[t].y;
}
for(let t = tstar + 1; t < T; t++) {
arr[t] = {
x: t,
y: arr[t - 1].y - logistic_rate(arr[t - 1].y, rate2, asymptote_lower2, asymptote_upper)
};
arr[t].y2 = arr[t - 1].y2 + logistic_rate(arr[t - 1].y2, rate, asymptote_lower, asymptote_upper);
}
return arr;
}
Insert cell
logit = (x) => Math.log(x) - Math.log(1 - x)
Insert cell
logit(0.9)
Insert cell
inv_logit = (x) => Math.exp(x) / (Math.exp(x) + 1)
Insert cell
T = 50
Insert cell
logistic = (t, rate, timing) => 1 / (1 + Math.exp(-rate * (t - timing)))
Insert cell
logistic_rate = (y, rate, asymptote_lower, asymptote_upper) => rate * (y - asymptote_lower) * (1 - (y - asymptote_lower) / (asymptote_upper - asymptote_lower))

//asymptote_upper * inv_logit(logit((y - asymptote_lower) / (asymptote_upper - asymptote_lower)) + rate)
Insert cell
//
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more