-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat61-normal-computed.tex
133 lines (126 loc) · 4.79 KB
/
stat61-normal-computed.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
%%%%%%%%%%%%%%%%%%%%
% WARNING: these Lua computations are not precise to all 4 decimal places (yet)
%%%%%%%%%%%%%%%%%%%%
\RequirePackage{luatex85}
\documentclass[12pt]{article}
\usepackage[margin=0.5in, bottom=0.35in, columnsep=1.0in]{geometry}
\usepackage{graphicx, adjustbox, tikz-cd, amsmath, amssymb, multicol, lscape, mathtools, etoolbox, xlop}
\setlength\parindent{0pt}
%% DEFINE \Repeat{n}{content}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \Repeat \prg_replicate:nn
\ExplSyntaxOff
%% DEFINE \normal{scale}{zscore}
\def\luamath#1{\edef\luamathresult{\directlua{tex.write("" .. #1)}}}
\newcommand\normal[2]{
\pgfmathparse{#2 > 0 ? 1 : -1}%
\edef\sign{\pgfmathresult}%
\pgfmathparse{abs(#2)}%
\edef\x{\pgfmathresult}%
\pgfmathparse{#1}%
\pgfmathroundto\pgfmathresult
\edef\scale{\pgfmathresult}%
\luamath{((\sign+1)/2 - \sign
*(2*3.14159265358979323846*2.718281828459045^(\x^2))^-0.5
*(0.4361836/(1+0.33267*\x)
- 0.1201676/(1+0.33267*\x)^2
+ 0.9372980/(1+0.33267*\x)^3
)
)*\scale
}
\pgfmathparse{\luamathresult}
\pgfmathroundtozerofill\pgfmathresult
\edef\res{\pgfmathresult}
\xappto{\TableBody}{\pgfmathresult}
}
\begin{document}
\pagestyle{empty}
\thispagestyle{empty}
\begin{landscape}
\huge %\sf
Standard Normal table %Standard Normal Cumulative Distribution Function $F_Z$
\par\vspace{0.2in}\large\hfill
\begin{tikzcd}[column sep=3.5cm, row sep=-2mm]
\text{\LARGE standard units}\quad
\rar[leftrightarrow, "\text{\normalsize use table to convert}"]
& \quad\text{\LARGE percentile rank}
\\ \displaystyle\boldsymbol z\color{black} = \frac{x-\mu}\sigma\quad\,\,
& \quad\boldsymbol{P(z \text{ or less})}
\color{black} = \text{area left of }z
\end{tikzcd}
\hfill\hfill~
$\smash{\begin{matrix}\begin{tikzpicture}[thick, yscale=1.5, xscale=1.25]
\draw[smooth, domain=-2.5:2.5] plot (\x, {2.718^(-0.5*(\x*\x))});
\draw (1, {2.718^-0.5}) node[above right, outer sep=0.4pt] (fZ)
{\footnotesize$\color{black} y=(2\pi e^{\textstyle z^{\textstyle2}})^{\textstyle-0.5}$};
\draw (-2.8, 0) edge[->] (2.8, 0);
\draw (1.5,0) node[below] {$\boldsymbol z$} -- ++(up: {2.718^(-0.5*(1.5*1.5))});
\draw (0,0) node[below, black, outer sep=0.4pt] {\footnotesize0};
\draw (0, 0.33) node {$\boldsymbol{P(z\text{ or less})}$};
\end{tikzpicture}\end{matrix}}$
\hfill~\footnotesize
\pgfkeys{/pgf/number format/.cd, fixed, fixed zerofill, precision=4, skip 0., }%
\def\TableBody{}%
\foreach \ab in {34,...,0}{
\pgfmathparse{floor(\ab/10)} \pgfmathroundto\pgfmathresult \xdef\a{\pgfmathresult}
\pgfmathparse{mod(\ab, 10)} \pgfmathroundto\pgfmathresult \xdef\b{\pgfmathresult}
\xappto\TableBody{$-\a.\b$}
\foreach \c in {0, ..., 9}{\xappto\TableBody{& } \normal1{-\ab/10-\c/100}}
\xappto\TableBody{& $-\a.\b$ \noexpand\\ }
\ifnum\b=0 \xappto\TableBody{&&&&&&&&&&{} \noexpand\\ } \else \fi
}%
\xappto\TableBody{\noexpand\\[-4ex]}%
\foreach \ab in {0,...,34}{
\pgfmathparse{floor(\ab/10)} \pgfmathroundto\pgfmathresult \xdef\a{\pgfmathresult}
\pgfmathparse{mod(\ab, 10)} \pgfmathroundto\pgfmathresult \xdef\b{\pgfmathresult}
\ifnum\b=0 \xappto\TableBody{&&&&&&&&&&{} \noexpand\\ } \else \fi
\xappto\TableBody{$\a.\b$}
\foreach \c in {0, ..., 9}{\xappto\TableBody{& } \normal1{\ab/10+\c/100}}
\xappto\TableBody{& $\a.\b$ \noexpand\\ }
}%
\begin{adjustbox}{angle=270}
\def\arraystretch{0.68}%
\begin{tabular}{r@{\hspace{4.5mm}}
*5{c @{\hspace{2.5mm}}}@{\hspace{-0.5mm}}*5{@{\hspace{2.5mm}} c}@{\hspace{2mm}}r}
& 0.00 & 0.01 & 0.02 & 0.03 & 0.04 & 0.05 & 0.06 & 0.07 & 0.08 & 0.09 \\
&&&&&&&&&&{} \\
$\mathllap\le{-}3.5\mathrlap0$ & 0.0001\\
\TableBody
$\mathllap\ge3.5\mathrlap0$ & 0.0001\\
&&&&&&&&&&{} \\
& 0.00 & 0.01 & 0.02 & 0.03 & 0.04 & 0.05 & 0.06 & 0.07 & 0.08 & 0.09
\end{tabular}
\end{adjustbox}
\par\vfill\small
City University of New York / College of Staten Island / M Sunderland
\hfill\textcolor{black}{symmetry: $P(-z$ or less) = $1 - P(z$ or less)}
\end{landscape}
\pgfkeys{/pgf/number format/.cd, fixed, fixed zerofill, precision=0, skip 0.=false}
\def\TableBody{}
\foreach \ab in {0,...,30}{
\pgfmathparse{floor(\ab/10)} \pgfmathroundto\pgfmathresult \xdef\a{\pgfmathresult}
\pgfmathparse{mod(\ab, 10)} \pgfmathroundto\pgfmathresult \xdef\b{\pgfmathresult}
\xappto\TableBody{$\a.\b$}
\foreach \c in {0, ..., 9}{\xappto\TableBody{& .} \normal{10000}{\ab/10+\c/100}}
\xappto\TableBody{& $\a.\b$ \noexpand\\ }
\ifnum\a=0 \else \ifnum\b=0 \xappto\TableBody{\noexpand\hline} \else \fi \fi
}
\Repeat{2}{
\begin{landscape}
\begin{multicols}2
\def\arraystretch{1.25}
\center
\Repeat{2}{
\par\huge $F_Z$ table
\par\bigskip\bigskip\footnotesize
\begin{tabular}{r|*5{l@{\hspace{1.2mm}}}|*5{@{\hspace{1.2mm}}l}|l}
& .00 & .01 & .02 & .03 & .04 & .05 & .06 & .07 & .08 & .09 \\ \hline
\TableBody
& .00 & .01 & .02 & .03 & .04 & .05 & .06 & .07 & .08 & .09
\end{tabular}
}
\end{multicols}
\end{landscape}
}
\end{document}