2017-06-18 42 views
-2

我想使用任何python統計包來檢索正常PPCC分佈的臨界值。如何獲取這些關鍵值,例如在numpy或statlib中。假設我有5個樣本,並且我想在p 0.05檢索臨界值。我已經從這個網站的表(http://www.itl.nist.gov/div898/handbook/eda/section3/eda3676.htm),但我想知道如果這個表是可用的Python和如何使用。 謝謝。 (善良,我是一個新手程序員)統計和編程

+0

https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.stats.shapiro.html提到三種選擇。 –

回答

0

我還沒有找到這樣的表。但是,您可以像這樣在代碼中使用該表。

def normal_ppcc(x, n, level): 
    table = {3: [0.8687, 0.879], 4: [0.8234, 0.8666], 5: [0.824, 0.8786], 6: [0.8351, 0.888], 7: [0.8474, 0.897], 8: [0.859, 0.9043], 9: [0.8689, 0.9115], 10: [0.8765, 0.9173], 11: [0.8838, 0.9223], 12: [0.8918, 0.9267], 13: [0.8974, 0.931], 14: [0.9029, 0.9343], 15: [0.908, 0.9376], 16: [0.9121, 0.9405], 17: [0.916, 0.9433], 18: [0.9196, 0.9452], 19: [0.923, 0.9479], 20: [0.9256, 0.9498]} 
    if not n in table: 
     raise ValueError ('n not in table') 
    if not level in [0.01, 0.05]: 
     raise ValueError ('invalid level') 
    entry = 0 if level == 0.01 else 1 
    return x < table[n][entry] 

print (normal_ppcc(0.985, 10, 0.05)) 
print (normal_ppcc(0.8764, 10, 0.01)) 
print (normal_ppcc(0.9172, 10, 0.05)) 
print (normal_ppcc(0.92, 10, 0.05)) 

要創建表,我將表複製粘貼到新的編輯器窗口中,然後運行此Python代碼。然後我將輸出複製粘貼到上面的代碼中。

lines = '''\ 
3  0.8687  0.8790 
4  0.8234  0.8666 
5  0.8240  0.8786 
6  0.8351  0.8880 
7  0.8474  0.8970 
8  0.8590  0.9043 
9  0.8689  0.9115 
10  0.8765  0.9173 
11  0.8838  0.9223 
12  0.8918  0.9267 
13  0.8974  0.9310 
14  0.9029  0.9343 
15  0.9080  0.9376 
16  0.9121  0.9405 
17  0.9160  0.9433 
18  0.9196  0.9452 
19  0.9230  0.9479 
20  0.9256  0.9498''' 

table = {} 
for line in lines.split('\n'): 
    n, x_01, x_05 = line.split() 
    table[int(n)] = [float(x_01), float(x_05)] 
print (table) 
+0

謝謝@BillBell。我希望桌子已經在統計軟件包中。我想這將不得不做。 – Coderflo

+0

謝謝@Bill Bell。我希望可以在任何python統計數據包中使用關鍵值。我想這將不得不做。 – Coderflo