สถิติเบื้องต้นด้วย Python
Maggie Matsui
Content Developer, DataCamp




ค่าที่คาดหวัง: ค่าเฉลี่ยของการแจกแจงความน่าจะเป็น
ค่าที่คาดหวังของการโยนลูกเต๋าสมดุล = $(1 \times \frac{1}{6}) + (2 \times \frac{1}{6}) +(3 \times \frac{1}{6}) +(4 \times \frac{1}{6}) +(5 \times \frac{1}{6}) +(6 \times \frac{1}{6}) = 3.5$

$$P(\text{die roll}) \le 2 = ~?$$

$$P(\text{die roll}) \le 2 = 1/3$$


ค่าที่คาดหวังของการโยนลูกเต๋าไม่สมดุล = $(1 \times \frac{1}{6}) +(2 \times 0) +(3 \times \frac{1}{3}) +(4 \times \frac{1}{6}) +(5 \times \frac{1}{6}) +(6 \times \frac{1}{6}) = 3.67$

$$P(\text{uneven die roll}) \le 2 = ~?$$

$$P(\text{uneven die roll}) \le 2 = 1/6$$

อธิบายความน่าจะเป็นสำหรับผลลัพธ์แบบไม่ต่อเนื่อง

การแจกแจงสม่ำเสมอแบบไม่ต่อเนื่อง

print(die)
number prob
0 1 0.166667
1 2 0.166667
2 3 0.166667
3 4 0.166667
4 5 0.166667
5 6 0.166667
np.mean(die['number'])
3.5
rolls_10 = die.sample(10, replace = True)
rolls_10
number prob
0 1 0.166667
0 1 0.166667
4 5 0.166667
1 2 0.166667
0 1 0.166667
0 1 0.166667
5 6 0.166667
5 6 0.166667
...
rolls_10['number'].hist(bins=np.linspace(1,7,7))
plt.show()


np.mean(rolls_10['number']) = 3.0

mean(die['number']) = 3.5

np.mean(rolls_100['number']) = 3.4

mean(die['number']) = 3.5

np.mean(rolls_1000['number']) = 3.48

mean(die['number']) = 3.5
เมื่อขนาดตัวอย่างเพิ่มขึ้น ค่าเฉลี่ยของตัวอย่างจะเข้าใกล้ค่าที่คาดหวัง
| ขนาดตัวอย่าง | ค่าเฉลี่ย |
|---|---|
| 10 | 3.00 |
| 100 | 3.40 |
| 1000 | 3.48 |
สถิติเบื้องต้นด้วย Python