Skip to content

High precision function generator to achieve desired probability

Notifications You must be signed in to change notification settings

ankurparihar/probability-function-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

High precision random function generator using binary generator

Generates a sequence of probability variable that when attached to unbiased random number generator gives the desired probability
In other words: Given the probability generate a function which returns 1 with that probability

  • Binary Generator: emmits only 0 or 1

working

Inputs

  • desired probability (best when it's binary representation is finite)
  • desired binary precision (i.e. precision upto no of digits after decimal when probability value is written in binary format)

Output

  • A sequence with variable p. p has probability 1/2;

Example

  • $ ./generator
  • $ Enter the probability: 0.83
  • $ Precision in binary digits: 15
  • $ p | p | p | p | p * p * (p | p | p * p * (p | p | p * p * p))
  • # Replace all p's in this sequence with an unbiased random number generator with outcome 0 or 1
  • >>> p() | p() | p() | p() | p() * p() * (p() | p() | p() * p() * (p() | p() | p() * p() * p()))

Testing

  • Use test.cpp or any program of your choice to test the accuracy

Other ways

If you have a general purpose random number generator which emmits at least 100 values than use equiprobable feature

About

High precision function generator to achieve desired probability

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages