Two independent normal distributions
Rohit has two freelance jobs. The pay for each job follows two independent normal distributions:
income1from Rohit's first job has a mean of $500 and a standard deviation of $50income2from Rohit's second job has a mean of $1,000 and a standard deviation of $200
Rohit has asked for your help simulating his income so that he can budget his expenses properly. You'll use sampling to find the 95% confidence interval of Rohit's total income from both jobs.
You are going to perform simulations using normal distributions, which are probably the most important probability distribution used in Monte Carlo simulation.
The following have been imported for you: NumPy as np, and SciPy's stats module as st.
Questo esercizio fa parte del corso
Monte Carlo Simulations in Python
Istruzioni dell'esercizio
- Use
st.norm.rvs()to sample 1,000 times from the normal distribution, setting the proper mean and standard deviation and assigning the results toincome1andincome2. - Approximate
total_incomeby addingincome1andincome2together.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Sample from the normal distribution
income1 = ____
income2 = ____
# Define total_income
total_income = ____
upper = np.quantile(total_income, 0.975)
lower = np.quantile(total_income, 0.025)
print([lower, upper])