Published
Edited
Mar 15, 2022
Insert cell
# Death's Dice
Insert cell
Insert cell
Insert cell
Insert cell
function* simulation(targetYear) {
const 생존확률계산 = (year) => {
const 주사위면수 = 2 * year;
const 사망확률 = 1 / 주사위면수 ** 2;
return 1 - 사망확률;
};
const data = [{ year: 0, 생존확률: 1, 누적생존확률: 1 }];
let 누적생존확률 = 1;
for (let year = 1; year < targetYear; year++) {
const 생존확률 = 생존확률계산(year);
누적생존확률 = 누적생존확률 * 생존확률;
data[year] = { year, 생존확률, 누적생존확률 };
yield data;
}
}
Insert cell
simData = simulation(100, run)
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