Parent

Class/Module Index [+]

Quicksearch

Statsample::Test::T::OneSample

One Sample t-test

Usage

a=1000.times.map {rand(100)}.to_scale
t_1=Statsample::Test::T::OneSample.new(a, {:u=>50})
t_1.summary

Output

= One Sample T Test
Sample mean: 48.954
Population mean:50
Tails: both
t = -1.1573, p=0.2474, d.f=999

Attributes

opts[RW]

Options

name[RW]

Name of test

u[RW]

Population mean to contrast

df[R]

Degress of freedom

tails[RW]

Tails for probability (:both, :left or :right)

Public Class Methods

new(vector, opts=Hash.new) click to toggle source

Create a One Sample T Test Options:

  • :u = Mean to compare. Default= 0

  • :name = Name of the analysis

  • :tails = Tail for probability. Could be :both, :left, :right

# File lib/statsample/test/t.rb, line 87
def initialize(vector, opts=Hash.new)
  @vector=vector
  default={:u=>0, :name=>"One Sample T Test", :tails=>:both}
  @opts=default.merge(opts)
  @name=@opts[:name]
  @u=@opts[:u]
  @tails=@opts[:tails]
  @df= @vector.n_valid-1
  @t=nil
end

Public Instance Methods

probability() click to toggle source
# File lib/statsample/test/t.rb, line 101
def probability
  p_using_cdf(Distribution::T.cdf(t, @df), tails)
end
t() click to toggle source
# File lib/statsample/test/t.rb, line 97
def t
  T.one_sample(@vector.mean, @u, @vector.sd, @vector.n_valid)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.