Class: Rust::StatisticalTests::Result
Overview
Represents the result of a statistical hypothesis test.
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#exact ⇒ Object
Returns the value of attribute exact.
-
#hypothesis ⇒ Object
Returns the value of attribute hypothesis.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pvalue ⇒ Object
Returns the value of attribute pvalue.
-
#statistics ⇒ Object
Returns the value of attribute statistics.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#adjusted_pvalue(method = 'bonferroni') ⇒ Object
If a hypothesis is available, returns the adjusted p-value with respect to all the other results obtained for the same hypothesis.
-
#initialize ⇒ Result
constructor
A new instance of Result.
-
#significant ⇒ Object
Returns true if the results are significant according to the specified alpha.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Result
Returns a new instance of Result.
19 20 21 |
# File 'lib/rust/stats/tests.rb', line 19 def initialize @statistics = {} end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
16 17 18 |
# File 'lib/rust/stats/tests.rb', line 16 def alpha @alpha end |
#exact ⇒ Object
Returns the value of attribute exact.
15 16 17 |
# File 'lib/rust/stats/tests.rb', line 15 def exact @exact end |
#hypothesis ⇒ Object
Returns the value of attribute hypothesis.
17 18 19 |
# File 'lib/rust/stats/tests.rb', line 17 def hypothesis @hypothesis end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/rust/stats/tests.rb', line 12 def name @name end |
#pvalue ⇒ Object
Returns the value of attribute pvalue.
14 15 16 |
# File 'lib/rust/stats/tests.rb', line 14 def pvalue @pvalue end |
#statistics ⇒ Object
Returns the value of attribute statistics.
13 14 15 |
# File 'lib/rust/stats/tests.rb', line 13 def statistics @statistics end |
Instance Method Details
#[](name) ⇒ Object
23 24 25 |
# File 'lib/rust/stats/tests.rb', line 23 def [](name) return @statistics[name.to_sym] end |
#[]=(name, value) ⇒ Object
27 28 29 |
# File 'lib/rust/stats/tests.rb', line 27 def []=(name, value) @statistics[name.to_sym] = value end |
#adjusted_pvalue(method = 'bonferroni') ⇒ Object
If a hypothesis is available, returns the adjusted p-value with respect to all the other results obtained for the same hypothesis. Otherwise, simply returns the p-value for this result. The method
for adjustment can be optionally specified (Bonferroni, by default).
36 37 38 39 |
# File 'lib/rust/stats/tests.rb', line 36 def adjusted_pvalue(method='bonferroni') return @pvalue unless @hypothesis @hypothesis.adjusted_pvalue_for(self, method) end |
#significant ⇒ Object
Returns true if the results are significant according to the specified alpha.
53 54 55 |
# File 'lib/rust/stats/tests.rb', line 53 def significant pvalue < alpha end |
#to_s ⇒ Object
57 58 59 60 61 62 |
# File 'lib/rust/stats/tests.rb', line 57 def to_s return "#{name}. P-value = #{pvalue} " + "(#{significant ? "significant" : "not significant"} w/ alpha = #{alpha}); " + "#{ statistics.map { |k, v| k.to_s + " -> " + v.to_s }.join(", ") }." + (!exact ? " P-value is not exact." : "") end |