Actions

Talk

Difference between revisions of "T distribution table"

From OPOSSEM

(Created page with "The [http://www.r-project.org/ R] source code for generating this table is as follows: <syntaxhighlight lang="rsplus"> # Generate a table of cumulative probabilities for the t ...")
 
 
Line 29: Line 29:
  
 
xtab <- xtable(m, digits=3)
 
xtab <- xtable(m, digits=3)
print(xtab, type="html", file="ttable.html", html.table.attributes='border="1" cellspacing="0" cellpadding="2" align="center" style="text-align: center;"')
+
print(xtab, type="html", file="ttable.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 11:10, 8 July 2011

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

# Generate a table of cumulative probabilities for the t 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.

tval <- c(0.95, 0.975, 0.995)
df <- c(1:39, seq(40, 120, by=10), 200, Inf)

m <- t(round(outer(tval, df, function(a, b) qt(a, b, lower=T)), 3))

df[length(df)] <- '∞'
colnames(m) <- c('90%', '95%', '99%')
rownames(m) <- df
library(xtable)

xtab <- xtable(m, digits=3)
print(xtab, type="html", file="ttable.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.