https://github.com/dinhanhx/biased-things
Methods to generate outcomes from biased coin, dice, list
https://github.com/dinhanhx/biased-things
beginner-code beginner-friendly biased coin dice java list random
Last synced: 6 months ago
JSON representation
Methods to generate outcomes from biased coin, dice, list
- Host: GitHub
- URL: https://github.com/dinhanhx/biased-things
- Owner: dinhanhx
- License: mit
- Created: 2019-10-23T01:46:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-12T04:04:41.000Z (about 6 years ago)
- Last Synced: 2025-03-23T18:12:40.715Z (10 months ago)
- Topics: beginner-code, beginner-friendly, biased, coin, dice, java, list, random
- Language: Java
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# biased-things
biased coin
biased dice
biased list
# Biased coin:
Method: public static boolean flip(double p)
Instruction: you input a value which is smaller 1 and bigger than 1. The value will be the chance of true.
Example: p = 0.9. The chance of getting true is 0.9 while the chance of getting false is 0.1
# Biased dice:
Method: public static int roll(double p1, double p2, double p3, double p4, double p5, double p6)
Instruction: you input 6 values which sum of them are 1.0
Example: p1 = 0.1; p2 = 0.1; p3 = 0.1; p4 = 0.1; p5 = 0.1; p6 = 0.5. The chance of getting 6 is 0.5 etc.
# Biased list:
Method: public static int pick(double[] p)
Instruction: you pass an array of real values which sum of them are 1.0
Example: double[] p = {0.1, 0.2, 0.3, 0.4}; The chance of getting 3rd element is 0.4 etc.
## Note:
Please run and try out codes to understand more.
All methods use all basic programming concepts, which mean that it's easy to implement on other languages.