Actions

Talk

Difference between revisions of "Standard normal table"

From OPOSSEM

(source code for table)
 
Line 1: Line 1:
The [http://www.r-project.org/ R] source code for generating this table is as follows:
+
The [http://www.r-project.org/ R] source code for generating this table is as follows:  
 
+
<nowiki>
<syntaxhighlight lang="R">
 
 
# Generate a table of cumulative probabilities for the standard normal
 
# Generate a table of cumulative probabilities for the standard normal
 
# distribution for the wiki textbook.
 
# distribution for the wiki textbook.
Line 21: Line 20:
 
Z <- seq(0, 3.99, by=0.01)
 
Z <- seq(0, 3.99, by=0.01)
 
q <- round(pnorm(seq(0, 3.99, by=0.01), lower=T)-0.5, 4)
 
q <- round(pnorm(seq(0, 3.99, by=0.01), lower=T)-0.5, 4)
 
##f <- data.frame(Z=Z, q=q)
 
  
 
m <- matrix(q, ncol=10, byrow=T)
 
m <- matrix(q, ncol=10, byrow=T)
Line 33: Line 30:
 
xtab <- xtable(m, digits=4)
 
xtab <- xtable(m, digits=4)
 
print(xtab, type="html", file="normaltable.html", html.table.attributes='border="1" cellspacing="0" cellpadding="2" align="center" style="text-align: center;"')
 
print(xtab, type="html", file="normaltable.html", html.table.attributes='border="1" cellspacing="0" cellpadding="2" align="center" style="text-align: center;"')
</syntaxhighlight>
+
</nowiki>
  
 
You will need the <tt>xtable</tt> package installed to generate the HTML table.
 
You will need the <tt>xtable</tt> package installed to generate the HTML table.

Revision as of 10:00, 8 July 2011

The R source code for generating this table is as follows:

# Generate a table of cumulative probabilities for the standard normal
# distribution for the wiki textbook.
#
# (C) 2011 Chris Lawrence <c.n.lawrence@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Z <- seq(0, 3.99, by=0.01)
q <- round(pnorm(seq(0, 3.99, by=0.01), lower=T)-0.5, 4)

m <- matrix(q, ncol=10, byrow=T)

rownames(m) <- format(seq(0, 3.9, by=0.1))
colnames(m) <- format(seq(0, 0.09, by=0.01))

library(xtable)

xtab <- xtable(m, digits=4)
print(xtab, type="html", file="normaltable.html", html.table.attributes='border="1" cellspacing="0" cellpadding="2" align="center" style="text-align: center;"')

You will need the xtable package installed to generate the HTML table.