0
0
SciPydata~10 mins

Uniform distribution in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the uniform distribution from scipy.stats.

SciPy
from scipy.stats import [1]
Drag options to blanks, or click blank then click option'
Anorm
Bbinom
Cuniform
Dpoisson
Attempts:
3 left
💡 Hint
Common Mistakes
Importing a different distribution like norm or binom instead of uniform.
2fill in blank
medium

Complete the code to create a uniform distribution object with lower bound 0 and upper bound 10.

SciPy
dist = uniform(loc=0, scale=[1])
Drag options to blanks, or click blank then click option'
A10
B5
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using the upper bound directly as scale without subtracting lower bound.
Setting scale to 0 or 1 incorrectly.
3fill in blank
hard

Fix the error in the code to calculate the probability density function (PDF) at x=5 for the uniform distribution.

SciPy
pdf_value = dist.[1](5)
Drag options to blanks, or click blank then click option'
Acdf
Bppf
Cpmf
Dpdf
Attempts:
3 left
💡 Hint
Common Mistakes
Using pmf which is for discrete distributions.
Using cdf instead of pdf.
4fill in blank
hard

Fill both blanks to create a dictionary of probabilities for values 2 and 8 using the PDF method.

SciPy
probabilities = {2: dist.[1](2), 8: dist.[2](8)}
Drag options to blanks, or click blank then click option'
Apdf
Bcdf
Cpmf
Dppf
Attempts:
3 left
💡 Hint
Common Mistakes
Using different methods for each value.
Using PMF or CDF instead of PDF.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each number in the list to its PDF value if the number is greater than 3.

SciPy
result = {num: dist.[1](num) for num in numbers if num [2] 3 and num [3] 10}
Drag options to blanks, or click blank then click option'
Apdf
B>
C<
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators.
Using PMF or CDF instead of PDF.