Answer the question
In order to leave comments, you need to log in
How to solve a programming problem?
Good afternoon! I can't figure out how to solve the following programming problem:
Write a program that from a random Bernoulli variable with p = q = 0.5 and simple
mathematical operations one could obtain a random Bernoulli variable with
any given p ∈ [0,1].
Answer the question
In order to leave comments, you need to log in
Let's say you have a function that returns a random number between 0 and 1 with equal probability.
And you need to get heads or tails with a probability of heads of 60%
It's simple: get a random number from 0 to 1 and compare with 0.6
Get < 0.6 probability 60 %, more than 40%.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question