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
148 changes: 142 additions & 6 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,118 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"heights = [167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195]\n",
"heights"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"173.46666666666667"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mean = sum(heights) / len(heights)\n",
"mean"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7.356888576280704"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import statistic\n",
"\n",
"std = statistics.stdev(heights)\n",
"std"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"import pandas as pd\n",
"import numpy as np\n",
"import scipy.stats as st"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(heights)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(171.0323076132764, 175.90102572005694)"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"st.norm.interval(0.8, loc=mean, scale = std/np.sqrt(15))"
]
},
{
Expand All @@ -51,11 +158,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"80% Confidence Interval: (0.20248138545542083, 0.3118043288302934)\n",
"90% Confidence Interval: (0.18698561776452813, 0.3273000965211861)\n"
]
}
],
"source": [
"# your code here"
"from scipy.stats import norm\n",
"import math\n",
"import scipy.stats as stats\n",
"import numpy as np\n",
"\n",
"n = 105\n",
"shops_with_losses = 27\n",
"\n",
"p_hat = shops_with_losses / n\n",
"\n",
"z_80 = norm.ppf(0.9)\n",
"z_90 = norm.ppf(0.95)\n",
"\n",
"margin_error_80 = z_80 * math.sqrt((p_hat * (1 - p_hat)) / n)\n",
"margin_error_90 = z_90 * math.sqrt((p_hat * (1 - p_hat)) / n)\n",
"\n",
"confidence_interval_80 = (p_hat - margin_error_80, p_hat + margin_error_80)\n",
"confidence_interval_90 = (p_hat - margin_error_90, p_hat + margin_error_90)\n",
"\n",
"print(f\"80% Confidence Interval: {confidence_interval_80}\")\n",
"print(f\"90% Confidence Interval: {confidence_interval_90}\")\n"
]
},
{
Expand Down Expand Up @@ -145,7 +281,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down