let simulation = new Simulation()
.setParameters(() => ({
hits: 0
}))
.setExperiment((params, { random }) => {
let [ x, y ] = random(2)();
params.hits += Math.sqrt(x ** 2 + y ** 2) < 1;
})
.setAggregate(({ hits }, { iterations }) => {
let pi = hits / iterations * 4;
console.log(`${ pi.toFixed(4) } - estimated value of PI`);
})
.setIterations(30000)
.runWhile((_, { experimentCount }) =>
experimentCount < 10);
-
Notifications
You must be signed in to change notification settings - Fork 0
Monte Carlo experiments
License
ichko/monte-carlo
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Monte Carlo experiments
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published