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
104 changes: 94 additions & 10 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# Libraries"
"# Libraries\n",
"import scipy.stats as st\n",
"import numpy as np\n"
]
},
{
Expand All @@ -32,11 +34,55 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(172.14308590115726, 174.79024743217607)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here"
"heights = np.array([167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195])\n",
"\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": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(170.9117270472475, 176.02160628608584)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#This is using t distribution, we dont have more than 30 observations\n",
"\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))\n"
]
},
{
Expand All @@ -51,11 +97,49 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Our CI for porpotion is [0.20248138545542083,0.3118043288302934]\n"
]
}
],
"source": [
"# your code here"
"losses= 27\n",
"p=losses/n\n",
"n=105\n",
"#80% confidence\n",
"z_value = st.norm.ppf(1-(1-0.80)/2)\n",
"se = np.sqrt((p * (1-p))/n)\n",
"margin_of_error = z_value * se\n",
"lower_bound = p- margin_of_error\n",
"upper_bound = p+ margin_of_error\n",
"print(f\"Our CI for porpotion is [{lower_bound},{upper_bound}]\")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(0.20248138545542083, 0.3118043288302934)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#with st.norm - we dont need here the z value \n",
"st.norm.interval(0.80, loc = p, scale = se)"
]
},
{
Expand Down Expand Up @@ -131,7 +215,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -145,7 +229,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down