0
0
SciPydata~20 mins

Probability density and cumulative functions in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Probability Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of PDF calculation for normal distribution
What is the output of this code snippet that calculates the probability density function (PDF) of a normal distribution at x=0?
SciPy
from scipy.stats import norm
result = norm.pdf(0, loc=0, scale=1)
print(round(result, 4))
A0.3989
B0.5000
C1.0000
D0.0000
Attempts:
2 left
💡 Hint
Recall the formula for the PDF of a standard normal distribution at zero.
data_output
intermediate
2:00remaining
Cumulative distribution function values for uniform distribution
What is the output array of cumulative distribution function (CDF) values for a uniform distribution between 0 and 10 at points [0, 5, 10, 15]?
SciPy
from scipy.stats import uniform
import numpy as np
points = np.array([0, 5, 10, 15])
cdf_values = uniform.cdf(points, loc=0, scale=10)
print(np.round(cdf_values, 2))
A[0.00 0.25 0.50 0.75]
B[0.00 0.40 0.80 1.00]
C[0.00 0.50 1.00 1.00]
D[0.10 0.50 0.90 1.00]
Attempts:
2 left
💡 Hint
CDF of uniform distribution increases linearly from 0 to 1 over the scale.
visualization
advanced
3:00remaining
Plot PDF and CDF of exponential distribution
Which option produces the correct plot showing both the PDF and CDF of an exponential distribution with rate 1 over the range 0 to 5?
SciPy
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import expon
x = np.linspace(0, 5, 100)
plt.plot(x, expon.pdf(x), label='PDF')
plt.plot(x, expon.cdf(x), label='CDF')
plt.legend()
plt.show()
APlot with PDF and CDF both starting at 0 and increasing to 1
BPlot with PDF curve starting at 1 and decreasing, CDF curve starting at 0 and increasing to 1
CPlot with PDF curve increasing, CDF curve decreasing
DPlot with flat PDF and CDF curves
Attempts:
2 left
💡 Hint
Remember the shape of exponential PDF and CDF functions.
🧠 Conceptual
advanced
2:00remaining
Understanding the relationship between PDF and CDF
Which statement correctly describes the relationship between the probability density function (PDF) and the cumulative distribution function (CDF) of a continuous random variable?
AThe PDF is the square of the CDF.
BThe PDF is the integral of the CDF from negative infinity to x.
CThe PDF and CDF are always equal for all x.
DThe CDF is the integral of the PDF from negative infinity to x.
Attempts:
2 left
💡 Hint
Think about how cumulative probability accumulates from the density.
🔧 Debug
expert
2:00remaining
Identify the error in this code calculating normal distribution CDF
What error does this code produce when trying to calculate the CDF of a normal distribution at x=1?
SciPy
from scipy.stats import norm
result = norm.cdf(1, mean=0, std=1)
print(result)
ATypeError: cdf() got an unexpected keyword argument 'mean'
BValueError: scale must be positive
CSyntaxError: invalid syntax
DOutput: 0.8413
Attempts:
2 left
💡 Hint
Check the parameter names for scipy.stats.norm.cdf.