0
0
SciPydata~10 mins

Probability density and cumulative functions in SciPy - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Probability density and cumulative functions
Start with a distribution
Calculate PDF at x
Calculate CDF at x
Use PDF for likelihood
Use CDF for cumulative probability
End
Start with a probability distribution, then calculate the PDF and CDF values at a point x to understand likelihood and cumulative probability.
Execution Sample
SciPy
from scipy.stats import norm
x = 0
pdf_val = norm.pdf(x)
cdf_val = norm.cdf(x)
print(pdf_val, cdf_val)
Calculate the PDF and CDF of the standard normal distribution at x=0.
Execution Table
StepActionInput xPDF CalculationPDF ResultCDF CalculationCDF Result
1Import norm from scipy.stats-----
2Set x value0----
3Calculate PDF at x0norm.pdf(0)0.3989422804014327--
4Calculate CDF at x0--norm.cdf(0)0.5
5Print results-0.39894228040143270.39894228040143270.50.5
6End-----
💡 Finished calculating PDF and CDF for x=0 in standard normal distribution.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
xundefined0000
pdf_valundefinedundefined0.39894228040143270.39894228040143270.3989422804014327
cdf_valundefinedundefinedundefined0.50.5
Key Moments - 2 Insights
Why is the PDF value at x=0 less than 1 even though it looks like a probability?
PDF values are densities, not probabilities. They can be less than 1 because they represent height under the curve, not direct probabilities. See execution_table row 3.
Why is the CDF value at x=0 exactly 0.5?
CDF gives cumulative probability up to x. For standard normal, half the data is below 0, so CDF at 0 is 0.5. See execution_table row 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the PDF value at step 3?
A0.5
B0.3989
C1.0
D0.0
💡 Hint
Check the 'PDF Result' column in row 3 of the execution_table.
At which step does the CDF get calculated?
AStep 4
BStep 3
CStep 2
DStep 5
💡 Hint
Look at the 'Action' column for 'Calculate CDF at x' in the execution_table.
If x was changed to 1, how would the PDF value change compared to step 3?
AIt would increase
BIt would stay the same
CIt would decrease
DIt would become zero
💡 Hint
Recall that PDF of normal distribution peaks at 0 and decreases as x moves away from 0.
Concept Snapshot
Probability Density Function (PDF) gives the height of the curve at x, showing likelihood density.
Cumulative Distribution Function (CDF) gives total probability up to x.
Use scipy.stats.norm.pdf(x) and .cdf(x) for standard normal.
PDF values can be less than 1; CDF values range from 0 to 1.
PDF is for density, CDF is for cumulative probability.
Full Transcript
We start with a probability distribution, here the standard normal. We pick a point x=0. We calculate the PDF at x=0 using norm.pdf, which gives about 0.3989. This is the height of the curve at zero, showing likelihood density. Then we calculate the CDF at x=0 using norm.cdf, which gives 0.5, meaning half the data lies below zero. We track variables x, pdf_val, and cdf_val through each step. Beginners often confuse PDF values with probabilities; PDF is a density, not a direct probability. Also, CDF at zero is 0.5 because the normal distribution is symmetric. Changing x affects PDF and CDF values accordingly.