Permutation tests

พื้นฐานการอนุมานทางสถิติด้วย Python

Paul Savala

Assistant Professor of Mathematics

Permutation tests

สองกลุ่มของตัวละครขนาดเล็ก แยกออกจากกัน แต่ละกลุ่มมีสีต่างกัน

พื้นฐานการอนุมานทางสถิติด้วย Python

Permutation tests

  • สุ่มสับเปลี่ยนตัวอย่าง
  • สังเกตผลลัพธ์
  • ความแตกต่างที่วัดได้ดูเหมือนผลแบบสุ่มหรือไม่?

ตัวละครขนาดเล็กกำลังถูกสลับที่กัน

พื้นฐานการอนุมานทางสถิติด้วย Python

Permutation tests ใน SciPy

new_satisfaction = [94, 85, 79, 91, 82]
old_satisfcation = [90, 87, 77, 85, 82]

# Group together our data data = (new_satisfaction, old_satisfcation)
# Define our test statistic def statistic(x, y): return np.mean(x) - np.mean(y)
# Compute a permutation test for the difference in means stats.permutation_test(data, statistic, n_resamples=1000, vectorized=False, alternative='greater')
พื้นฐานการอนุมานทางสถิติด้วย Python

Permutation tests สำหรับความสัมพันธ์

กราฟเส้นที่มีเส้นสีแดงและสีน้ำเงิน ทั้งสองเส้นมีความสัมพันธ์กันเล็กน้อย

stats.pearsonr(red_data, blue_data)[0]
0.08
พื้นฐานการอนุมานทางสถิติด้วย Python

Permutation tests สำหรับความสัมพันธ์

data = (red_data, blue_data)

def statistic(x, y): return stats.pearsonr(x, y)[0]
res = stats.permutation_test(data, statistic, n_resamples=1000, vectorized=False, alternative='two-sided')
print(res.pvalue < 0.05)
False
พื้นฐานการอนุมานทางสถิติด้วย Python

Permutation tests

 

  • สร้าง null distribution โดยการสับเปลี่ยนข้อมูลแบบสุ่ม
  • ทดสอบนัยสำคัญของผลลัพธ์

Bootstrapping

 

  • สร้างการกระจายความน่าจะเป็นโดยการสุ่มตัวอย่างข้อมูล
  • สร้าง confidence interval ที่แสดงผลลัพธ์ที่มีแนวโน้มมากที่สุด
พื้นฐานการอนุมานทางสถิติด้วย Python

มาฝึกกันเถอะ!

พื้นฐานการอนุมานทางสถิติด้วย Python

Preparing Video For Download...