Skip to content

Methods to generate outcomes from biased coin, dice, list

License

Notifications You must be signed in to change notification settings

dinhanhx/biased-things

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages