An open API service indexing awesome lists of open source software.

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

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.