You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "0237d0fb",
"metadata": {},
"source": [
"# Sampling variability\n",
"We create population (known distribution), then repeatedly take random samples and computes the sample mean. Then, we compare how variability changes for different sample sizes (n). "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "aa141540",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(np.float64(3.2549582990800525), np.float64(2.13814149865377))"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"rng = np.random.default_rng(7)\n",
"population = rng.lognormal(mean=1.0, sigma=0.6, size=200_000)\n",
"popMu = population.mean()\n",
"popSD = population.std(ddof=0)\n",
"popMu, popSD"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv (3.14.2)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}