Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 99 additions & 13 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Libraries"
"# Libraries\n",
"import scipy.stats as st\n",
"import numpy as np\n",
"from math import nan\n"
]
},
{
Expand All @@ -32,11 +35,54 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(172.14308590115726, 174.79024743217607)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here"
"# your code here\n",
"heights = np.array([167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195])\n",
"alpha = 0.80\n",
"std = 4\n",
"mean= np.mean(heights)\n",
"n= len(heights)\n",
"\n",
"st.norm.interval(0.80, loc =mean, scale = std/np.sqrt(n))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(170.9117270472475, 176.02160628608584)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# USING T-DIST\n",
"s= heights.std(ddof=1)\n",
"mean= heights.mean()\n",
"n=len(heights)\n",
"\n",
"st.t.interval(0.80, n-1, loc=mean, scale= s/np.sqrt(n))"
]
},
{
Expand All @@ -51,11 +97,51 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Our CI for porpotion is [0.20248138545542083,0.3118043288302934]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"sample_size= 105 \n",
"losses= 27\n",
"n=105\n",
"p=losses/sample_size\n",
"#80% confidence\n",
"z_value = st.norm.ppf(1-(1-0.80)/2)\n",
"se = np.sqrt((p*(1-p))/n) #standard error\n",
"margin_of_error = z_value * se\n",
"lower_bound = p- margin_of_error\n",
"upper_bound = p+ margin_of_error\n",
"\n",
"print(f\"Our CI for porpotion is [{lower_bound},{upper_bound}]\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.20248138545542083, 0.3118043288302934)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"st.norm.interval(0.80, loc=p, scale=np.sqrt ((p*(1-p))/n))"
]
},
{
Expand All @@ -76,11 +162,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"# your code here\n"
]
},
{
Expand All @@ -94,7 +180,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -121,7 +207,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -145,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down