class Statsample::Test::T::TwoSamplesIndependent
Two Sample t-test.
Usage¶ ↑
a=1000.times.map {rand(100)}.to_scale b=1000.times.map {rand(100)}.to_scale t_2=Statsample::Test::T::TwoSamplesIndependent.new(a,b) t_2.summary
Output¶ ↑
= Two Sample T Test Mean and standard deviation +----------+---------+---------+------+ | Variable | m | sd | n | +----------+---------+---------+------+ | 1 | 49.3310 | 29.3042 | 1000 | | 2 | 47.8180 | 28.8640 | 1000 | +----------+---------+---------+------+ == Levene Test Levene Test F: 0.3596 p: 0.5488 T statistics +--------------------+--------+-----------+----------------+ | Type | t | df | p (both tails) | +--------------------+--------+-----------+----------------+ | Equal variance | 1.1632 | 1998 | 0.2449 | | Non equal variance | 1.1632 | 1997.5424 | 0.1362 | +--------------------+--------+-----------+----------------+
Two Sample t-test.
Usage¶ ↑
a=1000.times.map {rand(100)}.to_scale b=1000.times.map {rand(100)}.to_scale t_2=Statsample::Test::T::TwoSamplesIndependent.new(a,b) t_2.summary
Output¶ ↑
= Two Sample T Test Mean and standard deviation +----------+---------+---------+------+ | Variable | m | sd | n | +----------+---------+---------+------+ | 1 | 49.3310 | 29.3042 | 1000 | | 2 | 47.8180 | 28.8640 | 1000 | +----------+---------+---------+------+ == Levene Test Levene Test F: 0.3596 p: 0.5488 T statistics +--------------------+--------+-----------+----------------+ | Type | t | df | p (both tails) | +--------------------+--------+-----------+----------------+ | Equal variance | 1.1632 | 1998 | 0.2449 | | Non equal variance | 1.1632 | 1997.5424 | 0.1362 | +--------------------+--------+-----------+----------------+
Attributes
df_equal_variance[R]
Degress of freedom (equal variance)
df_not_equal_variance[R]
Degress of freedom (not equal variance)
name[RW]
Name of test
opts[RW]
Options
probability_equal_variance[R]
Probability(equal variance)
probability_not_equal_variance[R]
Probability(unequal variance)
t_equal_variance[R]
Value of t for equal_variance
t_not_equal_variance[R]
Value of t for non-equal_variance
tails[RW]
Tails for probability (:both, :left or :right)
Public Class Methods
new(v1, v2, opts=Hash.new)
click to toggle source
Create a Two Independent T Test Options:
-
:name = Name of the analysis
-
:tails = Tail for probability. Could be :both, :left, :right
# File lib/statsample/test/t.rb, line 258 def initialize(v1, v2, opts=Hash.new) @v1=v1 @v2=v2 default={:u=>0, :name=>"Two Sample T Test", :tails=>:both} @opts=default.merge(opts) @name=@opts[:name] @tails=@opts[:tails] end
Public Instance Methods
compute()
click to toggle source
Set t and probability for given u
# File lib/statsample/test/t.rb, line 268 def compute @t_equal_variance= T.two_sample_independent(@v1.mean, @v2.mean, @v1.sd, @v2.sd, @v1.n_valid, @v2.n_valid,true) @t_not_equal_variance= T.two_sample_independent(@v1.mean, @v2.mean, @v1.sd, @v2.sd, @v1.n_valid, @v2.n_valid, false) @df_equal_variance=T.df_equal_variance(@v1.n_valid, @v2.n_valid) @df_not_equal_variance=T.df_not_equal_variance(@v1.sd, @v2.sd, @v1.n_valid, @v2.n_valid) @probability_equal_variance = p_using_cdf(Distribution::T.cdf(@t_equal_variance, @df_equal_variance), tails) @probability_not_equal_variance = p_using_cdf(Distribution::T.cdf(@t_not_equal_variance, @df_not_equal_variance), tails) end
d()
click to toggle source
Cohen's d is a measure of effect size. Its defined as the difference between two means divided by a standard deviation for the data
# File lib/statsample/test/t.rb, line 282 def d n1=@v1.n_valid n2=@v2.n_valid num=@v1.mean-@v2.mean den=Math::sqrt( ((n1-1)*@v1.sd+(n2-1)*@v2.sd).quo(n1+n2)) num.quo(den) end