Continuous distributions

Introduction to Statistics in Python

Maggie Matsui

Content Developer, DataCamp

Waiting for the bus

timeline from 1 to 2 pm with 6 bus arrivals, one every 12 mins

Introduction to Statistics in Python

Continuous uniform distribution

Set of axes with wait time on the x axis

Introduction to Statistics in Python

Continuous uniform distribution

Y axis becomes P(outcome = wait time) with a horizontal line going across the graph at 1/12

Introduction to Statistics in Python

Probability still = area

$$P(4 \le \text{wait time} \le 7) = ~~ ?$$

Area between 4 and 7 highlighted under the horizontal line

Introduction to Statistics in Python

Probability still = area

$$P(4 \le \text{wait time} \le 7) = ~~ ?$$

Width of highlighted area is 7-4=3, height is 1/12

Introduction to Statistics in Python

Probability still = area

$$P(4 \le \text{wait time} \le 7) = 3 \times 1/12 = 3/12$$

Width of highlighted area is 7-4=3, height is 1/12

Introduction to Statistics in Python

Uniform distribution in Python

$$ P(\text{wait time} \le 7)$$

Area highlighted from 0 to 7 under horizontal line

from scipy.stats import uniform

uniform.cdf(7, 0, 12)
0.5833333
Introduction to Statistics in Python

"Greater than" probabilities

$$ P(\text{wait time} \ge 7) = 1 - P(\text{wait time} \le 7)$$

Area highlighted from 7 to 12

from scipy.stats import uniform
1 - uniform.cdf(7, 0, 12)
0.4166667
Introduction to Statistics in Python

$$ P(4 \le \text{wait time} \le 7)$$

Area highlighted from 4 to 7

Introduction to Statistics in Python

$$ P(4 \le \text{wait time} \le 7)$$

Area highlighted from 0 to 7

Introduction to Statistics in Python

$$ P(4 \le \text{wait time} \le 7)$$

Area from 0-4 lightly highlighted, area from 4-7 highlighted darker

from scipy.stats import uniform
uniform.cdf(7, 0, 12) - uniform.cdf(4, 0, 12)
0.25
Introduction to Statistics in Python

Total area = 1

$$P(0 \le \text{wait time} \le 12) = ~~ ?$$

Width of distribution = 1, height = 1/12

Introduction to Statistics in Python

Total area = 1

$$P(0 \le \text{outcome} \le 12) = 12 \times 1/12 = 1$$

Width of distribution = 1, height = 1/12

Introduction to Statistics in Python

Generating random numbers according to uniform distribution

from scipy.stats import uniform
uniform.rvs(0, 5, size=10)
array([1.89740094, 4.70673196, 0.33224683, 1.0137103 , 2.31641255,
       3.49969897, 0.29688598, 0.92057234, 4.71086658, 1.56815855])
Introduction to Statistics in Python

Other continuous distributions

 

Distribution with 2 peaks

 

bell-curve shaped distribution

Introduction to Statistics in Python

Other continuous distributions

 

Highlighted area under curve with text: area = 1

 

Highlighted area under bell-curve with text: area = 1

Introduction to Statistics in Python

Other special types of distributions

Normal distribution

Plot of normal distribution

Exponential distribution

Plot of exponential distribution

Introduction to Statistics in Python

Let's practice!

Introduction to Statistics in Python

Preparing Video For Download...