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
121 changes: 109 additions & 12 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -9,14 +10,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# Libraries"
"# Libraries\n",
"\n",
"import numpy as np\n",
"import scipy.stats as st"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -32,14 +37,50 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"172.59744399428203\n",
"174.3358893390513\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"\n",
"# confidence level of 80%\n",
"confidence_level = 0.80\n",
"\n",
"z_score = st.norm.ppf(confidence_level)\n",
"\n",
"heights = [167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195]\n",
"\n",
"mean = np.mean(heights)\n",
"\n",
"# Assuming that the standard deviation of the sizes in the population is 4\n",
"std = 4\n",
"n = len(heights)\n",
"\n",
"left = mean - z_score * (std / np.sqrt(n))\n",
"right = mean + z_score * (std / np.sqrt(n))\n",
"\n",
"print(left)\n",
"print(right)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -51,14 +92,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.32793330928514125\n",
"0.18635240500057298\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"\n",
"# confidence level of 80%\n",
"confidence_level = 0.80\n",
"\n",
"# In a sample of 105 shops with 27 losses \n",
"shops = 105\n",
"shops_losses = 27\n",
"sample_proportion = shops_losses / shops\n",
"\n",
"z_score = st.norm.ppf(confidence_level)\n",
"\n",
"error_margin = z_score* np.sqrt((sample_proportion * (1 - sample_proportion)) / 27)\n",
"\n",
"positive = sample_proportion + error_margin\n",
"negative = sample_proportion - error_margin\n",
"\n",
"print(positive)\n",
"print(negative)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(0.07983770947987007, 0.4344480048058441)\n"
]
}
],
"source": [
"# for the 90% confidence level\n",
"confidence_level = 0.90\n",
"\n",
"z_score = st.norm.ppf(confidence_level)\n",
"\n",
"error_margin1 = z_score * np.sqrt((sample_proportion * (1 - sample_proportion)) / 27)\n",
"\n",
"ci = st.norm.interval(0.90, loc = sample_proportion, scale = error_margin1)\n",
"\n",
"print(ci)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -76,14 +171,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -94,14 +190,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand All @@ -121,7 +218,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -145,7 +242,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down