Зміст курсу
Probability Theory Basics
Probability Theory Basics
Continuous Uniform Distribution
Continuous distribution describes the stochastic experiment with infinite possible outcomes.
Continuous uniform distribution
Continuous uniform distribution describes an experiment where all outcomes within the interval have an equal probability of occurring.
If the variable is uniformly distributed, we can use a geometrical approach to calculate probabilities.
Example
Consider a line segment of length 10
units. What is the probability of randomly selecting a point on the line segment such that the distance from the starting point to this point is between 3 and 7
units?
As a result, the position or the point is uniformly distributed on the line with length 10
.
We can simply divide the length of the desired interval by the whole length of the segment.
We can also use the .cdf()
method on the scipy.stats.uniform
class to calculate the corresponding probability:
from scipy.stats import uniform # Parameters of an experiment whole_length = 10 range_start = 3 range_end = 7 # Geometrical approach desired_length = range_end - range_start geom_proba = desired_length / whole_length print(f'Geometrical probability is {geom_proba:.4f}') # Using `.cdf()` method upper_cdf = uniform.cdf(range_end, loc=0, scale=whole_length) lower_cdf = uniform.cdf(range_start, loc=0, scale=whole_length) cdf_proba = upper_cdf - lower_cdf print(f'Probability using .cdf() is {cdf_proba:.4f}')
The first parameter of the .cdf()
method determines the point at which we calculate probability; loc
parameter determines the beginning of the segment, and scale
determines the length of the segment.
The .cdf()
method calculates the probability that an experiment's result falls into a certain interval: .cdf(interval_end) - .cdf(interval_start)
.
We will consider this method in more detail in Probability Theory Mastering course.
Дякуємо за ваш відгук!