From ad1a07cfa82a26f0609e811c32b1847e38c42800 Mon Sep 17 00:00:00 2001 From: Andrew Lorimer Date: Mon, 28 Jan 2019 17:45:12 +1100 Subject: [PATCH 1/1] add to sampling notes (combiantorics & permutations) --- spec/sampling.md | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/spec/sampling.md b/spec/sampling.md index 2205b4b..6ba0e05 100644 --- a/spec/sampling.md +++ b/spec/sampling.md @@ -1,21 +1,30 @@ +--- +header-includes: +- \usepackage{amsmath} +- \newcommand*{\perm}[2]{{}^{#1}\!P_{#2}}% +- \newcommand*{\comb}[2]{{}^{#1}C_{#2}}% +--- + # Sampling and Distributions **Population** - set of all eligible members **Sample** - subset of population, may be representative of population -**Random sample** - every element of population has equal chance of selection -**Population proportion $p$** - proportion of individuals in population with an attribute -**Sample proportion $\^p$** - +**Random sample** - every element of population has equal chance of selection (exactly representative) +**Population mean $\mu$** - mean of all values of one attribute in population. $\mu = {\Sigma \text{values} \over |\text{population}|}$ +**Sample mean $\overline{x}$** - mean of all values in a sample. Random variable. +**Population proportion $p$** - proportion of defectives in population (100% certainty) +**Sample proportion $\hat{p}$** - proportion of defectives in one sample (varies between samples) **Discrete random variable** - countable number of distinct values $$\sum \Pr(n)=1$$ ### Hypergeometric distribution -$$\Pr(X=x) = {{{\begin{Bmatrix} - D \\ - x \\ - \end{Bmatrix}}\begin{Bmatrix} {N-D} \\ {n-x} \end{Bmatrix} }\over\begin{Bmatrix}N \\ n \end{Bmatrix}}$$ +$$\Pr(X=x) = {{\binom Dx \binom {N-d}{N-x}} \over{\binom Nn}}$$ + +where $N$ is the size of population, $n$ is the size of the sample, and $D$ is the number of defectives in population +On CAS: Interactive -> Distribution -> HyperGeoPdf ### Generating random numbers Catalog -> `rand(a,b)` generates a random number between $a$ and $b$ @@ -23,7 +32,10 @@ Catalog -> `rand(a,b)` generates a random number between $a$ and $b$ ### Combinations -CAS: Advanced -> `nCr(n,r)` $= ^nC_r$ +$$^n C_r = {n! \over {r!\cdot (n-r)!}} = \binom nr$$ + +$n$ is population, $r$ is sample (i.e. no of combinations of $r$ in $n$) +CAS: Advanced -> `nCr(n,r)` $= ^nC_r$ ### Binomial distributions @@ -31,10 +43,12 @@ with replacement. probability of achieving $x$ successes in $n$ trials for random variable $X$: -$$\Pr(X=x)=\begin{Bmatrix} n \\ x \end{Bmatrix} p^x (1-p)^{n-x} \quad \text{for }x = 0,1,2, \dots, n$$ +$$\Pr(X=x)=\binom nx p^x (1-p)^{n-x} \quad \text{for }x = 0,1,2, \dots, n$$ where $p$ = probability of success on each trial -#### on CAS: +##### Simulate on CAS: + +`randBin(sample size, p^, no of samples)` -`randBin(sample size, p^, no of samples)` \ No newline at end of file +Can be used from Stats: Menu -> Stats -> Cal (bottom) -> Catalog -> Random Bin \ No newline at end of file -- 2.43.2