Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.2%) to scientific vocabulary
Keywords
Repository
A Monte Carlo Machine for the Monty Hall Problem
Basic Info
Statistics
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 1
- Releases: 8
Topics
Metadata Files
README.md
Montehall: a Monte Carlo machine for the Monty Hall problem
An over-engineered CLI app, and an experiment with TypeScript/JavaScript (ECMAScript) aimed at:
- Creating a simulation of the famous counterintuitive Monty Hall problem
- Solving the strategy problem with Monte Carlo methods
- Creating a simulation of a general Montehall Problem with $n$ number of doors
- Producing fairly readable code and Node.js solution suitable for a pretty good practice tutorial.
Inspired by Numberphile's Monty Hall problem video.
Setup
Node.js (latest v16.x, or higher) and NPM (v9.x) are required to run the app:
shell
npm install
npm run build
Or, using Docker and Bash (recommended)
bash
docker pull node
docker run --rm --volume=$(pwd):/src --workdir="/src" node npm install
docker run --rm --volume=$(pwd):/src --workdir="/src" node npm run build
Running the CLI app
Running the default simulation with a player that does not switch:
shell
npx montehall
or, with Docker and Bash
bash
docker run --rm --volume="$(pwd):/src" --workdir="/src" node npx montehall
A player who does not switches their door pick should statistically win 1/3
of the games, given a sufficiently large number of random game attempts.
However, a prudent, or "wise," player who switches pick should win 2/3
of the games, which can be simulated using the --wise option:
shell
npx montehall --wise
A list of available options is accessible from the CLI:
shell
npx montehall --help
Number of game simulations
The default number of simulated games is 16384.
This can be changed using the --games option, or by changing the value for
the games key in the config.json configuration file.
General Monte Hall problem
A standard (default) game has three doors. A general game has $n$ doors.
The CLI option --doors <number> can be used to specify the number of doors.
Examples:
shell
npx montehall --doors 100
npx montehall --doors 181 --games 1000 --wise
High-quality results
A randomness source is required to simulate the games. Achieving high-quality simulation results requires a high-quality randomness source.
The default source of randomness used is a fast pseudo one: the
Math.random()
function.
A higher quality randomness source
For a higher quality, but slower, randomness source,
use the --random advanced option, which employs a cryptographically
secure pseudorandom number generator (CSPRNG.)
shell
npx montehall --wise --random advanced
Using pre-generated random numbers (experimental)
A text file of numbers (random positive integers) can be loaded to run a deterministic simulation.
The file path can be passed as a CLI option:
shell
npx montehall --games 100 --table-file vendor/numbers.txt
Or, alternatively, the file path can be configured in config.json.
Example:
json
{
"numbersFilePath": "./data/numbers.txt"
}
shell
npx montehall --games 100 --random table
The file must have one number per text line. Example:
text
1
1
0
1
2
1
0
See vendor/numbers.txt for a sample file.
Technical showcases
Partial list of showcases, in alphabetical order:
- Asynchronous programming
- Azure Pipelines
- Behavior-driven development (BDD)
- CodeQL
- Coding without
null - Coding without classes
- Command-line interface (CLI)
- Commander.js
- Continuous integration
- Conventional Commits
- DevSkim
- Distribution package clean of development dependencies
- ECMAScript Modules
- ESLint
- Functional programming
- GitHub Actions
- High code test coverage
- Markdown
- Markdownlint
- Node.js
- NPM
- Prettier
- SonarCloud
- Strict static rules and type safety
- Symantec versioning
- TypeScript
- Unbiased pseudo-randomness
- Unit testing with Jest (and Jasmine)
License
This software is released under an MIT-style license. Copyright © 2017-2023 Omar Boukli-Hacene.
Written for the joy of it 🐻
Owner
- Name: Omar Boukli-Hacene
- Login: oboukli
- Kind: user
- Repositories: 4
- Profile: https://github.com/oboukli
Citation (CITATION.cff)
cff-version: 1.2.0
title: OBoukli Montehall
message: >-
If you use this software, kindly cite it using the
metadata from this file.
type: software
authors:
- given-names: Omar
family-names: Boukli Hacene
repository-code: "https://github.com/oboukli/montehall"
abstract: >-
A software Monte Carlo machine for the Monty Hall problem.
license: MIT
GitHub Events
Total
Last Year
Dependencies
- @types/jasmine 4.0.2 development
- @types/node 16.11.26 development
- balanced-match 1.0.2 development
- brace-expansion 1.1.11 development
- concat-map 0.0.1 development
- fs.realpath 1.0.0 development
- glob 7.2.0 development
- inflight 1.0.6 development
- inherits 2.0.4 development
- jasmine 4.1.0 development
- jasmine-core 4.1.0 development
- minimatch 3.1.2 development
- once 1.4.0 development
- path-is-absolute 1.0.1 development
- typescript 4.6.3 development
- wrappy 1.0.2 development
- bluebird 3.7.2
- commander 4.1.1
- create-error 0.3.1
- random-number-csprng 1.0.2
- @types/jasmine ^4.0.2 development
- @types/node ^16.11.26 development
- jasmine ^4.1.0 development
- typescript ^4.6.3 development
- commander ^4.1.1
- random-number-csprng ^1.0.2
- actions/checkout v3 composite
- actions/setup-node v3 composite
- actions/upload-artifact v3 composite
- actions/checkout v3 composite
- github/codeql-action/analyze v2 composite
- github/codeql-action/init v2 composite
- actions/checkout v3 composite