Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Visualizing Probability Distributions | Section
Exploring Probability Theory
セクション 1.  10
single

single

bookVisualizing Probability Distributions

メニューを表示するにはスワイプしてください

Visualizing probability distributions helps you gain a deeper understanding of how random variables behave. In Python, the matplotlib library is a powerful tool for creating such visualizations. You can use it to plot both probability mass functions (PMFs) for discrete distributions and probability density functions (PDFs) for continuous distributions.

To visualize a PMF, you typically use bar plots to represent the probabilities associated with each possible outcome. For continuous distributions, you plot the PDF as a smooth curve, showing how probability is distributed over a range of values. These plots allow you to quickly see where outcomes are most likely, spot symmetry or skewness, and compare different distributions.

When working with discrete distributions like the binomial, you often want to show the probability of getting a certain number of successes in a fixed number of trials. For continuous distributions like the normal distribution, you want to show how likely values are to fall within a certain interval. Using matplotlib, you can create clear, informative plots to support your analysis of probability problems.

12345678910111213141516171819202122232425262728
import numpy as np import matplotlib.pyplot as plt from scipy.stats import binom, norm # Plotting the Binomial Distribution (Discrete) n, p = 10, 0.5 # 10 trials, probability of success 0.5 x_binom = np.arange(0, n+1) pmf_binom = binom.pmf(x_binom, n, p) plt.figure(figsize=(8, 4)) plt.bar(x_binom, pmf_binom, color='skyblue', edgecolor='black') plt.title('Binomial Distribution PMF (n=10, p=0.5)') plt.xlabel('Number of Successes') plt.ylabel('Probability') plt.show() # Plotting the Normal Distribution (Continuous) mu, sigma = 0, 1 # mean and standard deviation x_norm = np.linspace(-4, 4, 1000) pdf_norm = norm.pdf(x_norm, mu, sigma) plt.figure(figsize=(8, 4)) plt.plot(x_norm, pdf_norm, color='darkorange') plt.title('Normal Distribution PDF (μ=0, σ=1)') plt.xlabel('Value') plt.ylabel('Density') plt.grid(True) plt.show()
copy
question mark

Which statement best describes how PMFs and PDFs are used when visualizing probability distributions?

正しい答えを選んでください

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  10
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt