Public
Edited
Sep 14, 2024
Paused
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Combine the data points into a single array
dataPoints = [
...x_1.map((x, i) => ({ x, y: y_1[i], dataset: 'y1' })),
...x_2.map((x, i) => ({ x, y: y_2[i], dataset: 'y2' }))
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Define the model function
function model(params, x, dataset) {
const [a, b, c] = params;
if (dataset === 'y1') {
return a * x + b;
} else if (dataset === 'y2') {
return a * x + c;
}
}
Insert cell
Insert cell
Insert cell
Insert cell
// Define bounds for parameters a, b, and c
bounds = {
return [
[0.999 * initialParams[0], 1.001 * initialParams[0]], // Bounds for a
[0.8 * initialParams[1], 1.2 * initialParams[1]], // Bounds for b
[0.9 * initialParams[2], 1.1 * initialParams[2]], // Bounds for c
];
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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