single
Random Variables and Probability Distributions
Deslize para mostrar o menu
A random variable is a function that assigns a numerical value to each outcome of a random experiment. Random variables are classified as either discrete or continuous.
A discrete random variable can take on a finite or countably infinite set of possible values. For instance, the number of heads when flipping three coins is a discrete random variable, as its possible values are 0, 1, 2, or 3.
A continuous random variable can take on any value within a given interval or collection of intervals. For example, the exact height of a randomly selected person is a continuous random variable, as it can be any real number within a certain range.
The probability mass function (PMF) describes the probability that a discrete random variable is exactly equal to some value. For a discrete random variable X, the PMF is defined as P(X=x). For example, if X is the roll of a fair six-sided die, the PMF assigns a probability of 1/6 to each possible outcome from 1 to 6.
The probability density function (PDF) is used for continuous random variables. It describes the relative likelihood for this random variable to take on a given value. Unlike the PMF, the PDF itself does not give probabilities directly; instead, the probability that the variable falls within a particular interval is given by the area under the curve of the PDF over that interval. For example, the time between bus arrivals might follow an exponential distribution with a specific PDF.
Understanding the distinction between PMF and PDF is crucial for working with different types of random variables and their distributions.
123456789101112131415161718import matplotlib.pyplot as plt import numpy as np # Simulate a discrete random variable: rolling a fair six-sided die 1000 times np.random.seed(42) n_trials = 1000 outcomes = np.random.choice([1, 2, 3, 4, 5, 6], size=n_trials) # Calculate the PMF (empirical probabilities) values, counts = np.unique(outcomes, return_counts=True) pmf = counts / n_trials # Plot the PMF plt.bar(values, pmf, tick_label=values) plt.xlabel("Die Face") plt.ylabel("Probability") plt.title("Empirical PMF of a Fair Six-Sided Die") plt.show()
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo