Permutation test के साथ skewed डेटा का विश्लेषण
Permutation tests तब उपयोगी होते हैं जब आपकी ज्ञात hypothesis tests की शर्तें पूरी नहीं होतीं। इस अभ्यास में आप statsmodels पैकेज का उपयोग करके एक permutation test कोड करेंगे.
आप analytics स्पेस की कंपनियों और बाकी सभी venture-funded कंपनियों के बीच औसत funding rounds की संख्या की तुलना करना चाहते हैं। भले ही आप t-test करने के लिए प्रेरित हों, आप जानते हैं कि funding rounds की संख्या सामान्य (normally) वितरण का पालन नहीं करती। अधिकतर कंपनियों के केवल एक ही राउंड होते हैं, और दो या अधिक राउंड वाली कंपनियों की संख्या तेज़ी से घट जाती है.
नीचे दिया गया डेटा आपके लिए पहले से लोड है:
analytics_df- सभी analytics कंपनियों का डेटाnon_analytics_df- अन्य सभी non-analytics कंपनियों का डेटा
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में अनुमान का आधार
अभ्यास निर्देश
- एक statistic फंक्शन परिभाषित करें, जो दो सैंपल
fundings_group_1औरfundings_group_2दिए जाने परfunding_roundsके mean का अंतर लौटाए. - प्रत्येक डेटा सेट के
funding_roundsकॉलम, आपके द्वारा परिभाषित statistic फंक्शन, और 100 resamples का उपयोग करके एक permutation test चलाएँ. - अपने permutation test की प्राप्त p-value प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Write a "statistic" function which calculates the difference in means
def statistic(funding_group_1, funding_group_2):
return ____(fundings_group_1) - ____(funding_group_2)
# Conduct a permutation test using 100 resamples
perm_result = stats.permutation_test((____['funding_rounds'], ____['funding_rounds']),
statistic=____,
n_resamples=____,
vectorized=____)
# Print the p-value
____(____.pvalue)