Actions

Talk

Difference between revisions of "Standard normal table"

From OPOSSEM

 
Line 29: Line 29:
  
 
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>
 
</syntaxhighlight>
  
 
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.

Latest revision as of 10:39, 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.