Advertisement
elena1234

Uniform Distribution in Python

Jul 5th, 2022
975
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None
  1. from scipy.stats import uniform
  2. # On average, 30 minutes TV shows have 22 minutes of actual program. Let's assume the probability distribution for number of minutes of actial program is uniform from a low of 18min to the high of 26min. What is the probability the show will have at least 25 minutes of programming?
  3.  
  4. loc: low boundary; scale: high - low boundary
  5. 1 - uniform.cdf(x = 25, loc = 18, scale = 8)
  6.  
  7. # What is the probability the show will have between 21 and 25 minutes of programming?
  8. uniform.cdf(x = 25, loc = 18, scale = 8) - uniform.cdf(x = 21, loc = 18, scale = 8)
  9.  
  10. # Which value is associated with 0.50 Probability?
  11. from scipy import stats
  12. stats.uniform.ppf(q = 0.5, loc = 18, scale = 8)
Advertisement
RAW Paste Data Copied
Advertisement