+1(978)310-4246 credencewriters@gmail.com
  

just follow the instuction from top to bottom write some function and plot the diagram
involve Python, linear algebra, confidence level, bootstrap linear_model{
“cells”: [
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“# Grade: /100 ptsn”,
“n”,
“# Assignment 04: Confidence Intervals & The Bootstrapn”,
“n”,
“Once you are finished, ensure to complete the following steps.n”,
“1. Restart your kernel by clicking ‘Kernel’ > ‘Restart & Run All’.n”,
“2. Fix any errors which result from this.n”,
“3. Repeat steps 1. and 2. until your notebook runs without errors.n”,
“4. Submit your completed notebook to OWL by the deadline.”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {},
“outputs”: [],
“source”: [
“# Add the necessary imports for this homework n”,
“import numpy as npn”,
“import pandas as pdn”,
“import matplotlib.pyplot as pltn”,
“import seaborn as snsn”,
“import sklearn.model_selectionn”,
“import sklearn.linear_model”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“### Question 1: /10pts n”,
“In this question, you will construct a confidence interval for the sample mean, not using the normal distribution, but the t-distribution (see end of lecture 4.3), which is more accurate for small sample sizes. n”,
“n”,
“The $100(1-\alpha)\%$ confidence interval is n”,
“n”,
“$$ \bar{x} \pm t_{1-\alpha/2, n-1} \dfrac{\hat{\sigma}}{\sqrt{n}} $$n”,
“n”,
“Where $ t_{1-\alpha/2, n-1}$ is the appropiorate quantile of a Student’s t distribution with $n-1$ degrees of freedom. n”,
“Write a function called `confidence_interval` which takes as it’s argument an array of data called `data` and returns two things:n”,
“n”,
“* An estimated mean of `data`, and n”,
“n”,
“* The lower and upper bounds of the 95% confidence interval for the mean of `data`. Ensure these are returned in a numpy array of shape (2,)n”,
“n”,
“To get the appropirate quantiles for the t-distribution, you can use `scipy.stats.t`, which implements some statistical functions for the t-distribution. Take a look at the documentation for `scipy.stats.t`, especially the `ppf` method.n”,
“n”,
“Here is the documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.t.htmln”
]
},
{
“cell_type”: “code”,
“execution_count”: null,
“metadata”: {},
“outputs”: [],
“source”: [
“def confidence_interval(data):n”,
“n”,
” # Note, np.std divides by n and not n-1n”,
” # Force it to apply the correct formula by ussing ddof=1n”,
” # Alternaively, you can use scipy.stats.sem to computen”,
” #The standard errorn”,
” n”,
” return estimated_mean, bounds”
]
},
{
“cell_type”: “markdown”,
“metadata”: {},
“source”: [
“### Question 2: /15ptsn”,
“n”,
“The “95% confidence interval”” is named so because the long term relative frequency of these estimators containing the true estimand is 95%. That is to say”

error: Content is protected !!