Skip to content

statistics-exercises/discrete-random-variables-9

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Generating negative binomial random variables

We have one final type of random variable to learn how to generate using python - the negative binomial random variable. If you remember the negative binomial random variables measures the number of trials I have to perform in order to obtain exactly k successes. A negative binomial random variables can be generated by generating k geometric random variables and adding them together.

To complete the exercise you will need to:

  • Write a function called bernoulli that takes in a parameter called p. This parameter gives the probability that the trial is successful - and that the function thus returns a 1

  • Use your bernoulli function in a second function called geometric. This geometric function should take one parameter p (the probability of success in each individual trial). The function should then return a geometric random variable.

  • Write one final function called negative_binomial. This negative_binomial function should take two parameters: p (the probability of success in each individual trial) and k (the number of successes that you would like to observe). The function should then return a negative binomial random variable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages