Normal distributions का standard deviation बदलें
आप अमेरिकी वयस्क पुरुषों की ऊँचाइयों का अन्वेषण जारी रखेंगे, जो आप अब जानते हैं कि mean 177 सेंटीमीटर और standard deviation 8 सेंटीमीटर के साथ normal distributed हैं.
इस अभ्यास में, आप normal distribution से sample लेंगे और औसत ऊँचाई का 95% confidence interval निकालेंगे। लेकिन इस बार, आप standard deviation को 15 कर देंगे, जबकि ऊँचाइयों का mean नहीं बदलेंगे। आप देखेंगे कि अगर आप फिर से sampling करते हैं, तो औसत ऊँचाई के mean और उसके confidence interval पर क्या असर पड़ता है!
आपके लिए ये पहले से import किए गए हैं: random, NumPy as np, और SciPy का stats मॉड्यूल st नाम से.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Monte Carlo Simulations
अभ्यास निर्देश
- normal distribution से 1,000 बार sample लें, जहाँ mean 177 है और standard deviation 15 है; परिणामों को
heights_177_15में स्टोर करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
random.seed(1231)
heights_177_8 = st.norm.rvs(loc=177, scale=8, size=1000)
print(np.mean(heights_177_8))
upper = np.quantile(heights_177_8, 0.975)
lower = np.quantile(heights_177_8, 0.025)
print([lower, upper])
# Sample 1,000 times from the normal distribution where the standard deviation is 15
heights_177_15 = ____
print(np.mean(heights_177_15))
upper = np.quantile(heights_177_15, 0.975)
lower = np.quantile(heights_177_15, 0.025)
print([lower, upper])