|
TTAILX.OMS
Script File:
# Description:
# Computes the tail probability for the T statistic.
#
clear
# grid of values for T statistic
t = seq(100) / 10.
# axis for T statistic
gxaxis("linear", 0, 10, 10, 5)
# axis for tail probability
gyaxis("linear", 0, .2, 2, 10)
# degrees of freedom
df = [1, 2, 4, 7]
# titles
gxtitle("T")
gytitle("probability")
for i = 1 to coldim(df) begin
# degrees of freedom
d = fill(df(i), 100, 1)
# probability
p = ttail(t, d)
# plot probability as a function of t
gplot(t, p)
# derivative of p with respect to t
dpdt = coldiff(p) / coldiff(t)
# points where dpdt >= -.1 / 10.
flag = dpdt >= -.1 / 10.
# determine corresponding indices in t and p
index = seq(99) + 1
index = index.row(flag)
# location of first point where dpdt >= -.1 / 10.
coord = gcoord(t(index(1)), p(index(1)))
# label curve with degrees of freedom
text = ntoa(df(i))
gaddtext(text, coord, [.5, .5]);
end
Output:
|
|