Class: Statsample::Test::T::OneSample
- Includes:
- Math, Summarizable, Statsample::Test
- Defined in:
- lib/statsample/test/t.rb
Overview
One Sample t-test
Usage
a=1000.times.map {rand(100)}.to_numeric
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
Instance Attribute Summary collapse
-
#df ⇒ Object
readonly
Degress of freedom.
-
#name ⇒ Object
Name of test.
-
#opts ⇒ Object
Options.
-
#tails ⇒ Object
Tails for probability (:both, :left or :right).
-
#u ⇒ Object
Population mean to contrast.
Instance Method Summary collapse
- #confidence_interval(cl = nil) ⇒ Object (also: #ci)
-
#initialize(vector, opts = Hash.new) ⇒ OneSample
constructor
Create a One Sample T Test Options: * :u = Mean to compare.
- #probability ⇒ Object
-
#report_building(b) ⇒ Object
:nodoc:.
- #standard_error ⇒ Object (also: #se)
- #t ⇒ Object
- #t_object ⇒ Object
Methods included from Summarizable
Methods included from Statsample::Test
chi_square, levene, #p_using_cdf, #t_critical, t_one_sample, t_two_samples_independent, u_mannwhitney, wilcoxon_signed_rank, #z_critical
Constructor Details
#initialize(vector, opts = Hash.new) ⇒ OneSample
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
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/statsample/test/t.rb', line 160 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] @confidence_level=@opts[:confidence_level] || 0.95 @df= @vector.n_valid-1 @t=nil end |
Instance Attribute Details
#df ⇒ Object (readonly)
Degress of freedom
151 152 153 |
# File 'lib/statsample/test/t.rb', line 151 def df @df end |
#name ⇒ Object
Name of test
147 148 149 |
# File 'lib/statsample/test/t.rb', line 147 def name @name end |
#tails ⇒ Object
Tails for probability (:both, :left or :right)
153 154 155 |
# File 'lib/statsample/test/t.rb', line 153 def tails @tails end |
#u ⇒ Object
Population mean to contrast
149 150 151 |
# File 'lib/statsample/test/t.rb', line 149 def u @u end |
Instance Method Details
#confidence_interval(cl = nil) ⇒ Object Also known as: ci
184 185 186 |
# File 'lib/statsample/test/t.rb', line 184 def confidence_interval(cl=nil) t_object.confidence_interval(cl) end |
#probability ⇒ Object
177 178 179 |
# File 'lib/statsample/test/t.rb', line 177 def probability t_object.probability end |
#report_building(b) ⇒ Object
:nodoc:
188 189 190 191 192 193 194 |
# File 'lib/statsample/test/t.rb', line 188 def report_building(b) # :nodoc: b.section(:name=>@name) {|s| s.text _("Sample mean: %0.4f | Sample sd: %0.4f | se : %0.4f") % [@vector.mean, @vector.sd, se] s.text _("Population mean: %0.4f") % u if u!=0 t_object.report_building_t(s) } end |
#standard_error ⇒ Object Also known as: se
180 181 182 |
# File 'lib/statsample/test/t.rb', line 180 def standard_error t_object.standard_error end |
#t ⇒ Object
174 175 176 |
# File 'lib/statsample/test/t.rb', line 174 def t t_object.t end |