random.binomial

random.binomial, function

def autodiff pure random.binomial(p: number): boolean

Draws a Bernoulli sample with success probability p.

Example

montecarlo 10000 with
  x = random.binomial(0.3)
  sample rate = avg(if x then 1 else 0)

show scalar "Success rate" with rate

This outputs the following scalar:

Success rate
0.2944

Remarks

This function is usable in autodiff blocks, but no gradient flows through it.

User Contributed Notes
0 notes + add a note