<jupyter_start><jupyter_text>DATA 5600: Introduction to Regression and Machine Learning for Analytics __CLT Examples__ Author:      <NAME> Updated: October 6, 2021 ---<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
from scipy import stats<jupyter_output><empty_output><jupyter_text>__Probability Distribution, Mean, and Variance of a Poisson Random Variable__---$$\begin{align}p(x) &= \frac{\lambda^{x} e^{-\lambda}}{x!} \quad x = 0, 2, \ldots \\     & \\\mu  &= \lambda \\     & \\\sigma^{2} &= \lambda \\\end{align}$$---where* $\lambda =$ mean number of events during given unit of time, area, volume, etc.* $e = 2.71828...$  __Poisson Example__Suppose the number, $x$, of a company's employees who are absent on Mondays has (approximately) a Poisson probability distribution. Further, assume that the average number of Monday absentees is 2.6.* (a) Find the mean and standard deviation of $x$ the number of employees absent on Monay. $$\begin{align}\mu &= \lambda = 2.6 \\& \\\sigma^{2} &= \lambda = 2.6\end{align}$$Then the standard deviation is: $\sqrt{2.6} = 1.61$<jupyter_code>λ = 2.6
n = 52 # weeks 
x = np.random.poisson(lam=λ, size=n)
x
xbar = np.mean(x)
xbar
sbar = np.std(x, ddof=1)
sbar
serr = sbar / np.sqrt(n)
z = (x - xbar) / sbar
M = 500_000
n = 104

xbars = np.zeros(M)

for i in range(M):
    xbars[i] = np.mean(np.random.poisson(lam=λ, size=n))
plt.hist(xbars, bins=25)
zbars = (xbars - λ) / (np.sqrt(λ) / np.sqrt(n))
plt.hist(zbars)
np.mean(zbars)
np.std(zbars,ddof=1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16276041666666666, 'fraction_numerical': 0.030598958333333332, 'mean_word_length': 4.022875816993464, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '258424', 'license': 'CC0-1.0', 'n_tokens_mistral': 611, 'n_tokens_neox': 558, 'n_words': 170, 'path': 'Lectures/Gelman et al/Chapter04/Untitled2.ipynb', 'repo_name': 'CAIJedi/DATA-5600-FL21', 'size': '1545'}