Class: Rust::StatisticalTests::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/rust-tests.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



12
13
14
# File 'lib/rust-tests.rb', line 12

def initialize
    @statistics = {}
end

Instance Attribute Details

#alphaObject

Returns the value of attribute alpha.



9
10
11
# File 'lib/rust-tests.rb', line 9

def alpha
  @alpha
end

#exactObject

Returns the value of attribute exact.



8
9
10
# File 'lib/rust-tests.rb', line 8

def exact
  @exact
end

#hypothesisObject

Returns the value of attribute hypothesis.



10
11
12
# File 'lib/rust-tests.rb', line 10

def hypothesis
  @hypothesis
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/rust-tests.rb', line 5

def name
  @name
end

#pvalueObject

Returns the value of attribute pvalue.



7
8
9
# File 'lib/rust-tests.rb', line 7

def pvalue
  @pvalue
end

#statisticsObject

Returns the value of attribute statistics.



6
7
8
# File 'lib/rust-tests.rb', line 6

def statistics
  @statistics
end

Instance Method Details

#[](name) ⇒ Object



16
17
18
# File 'lib/rust-tests.rb', line 16

def [](name)
    return @statistics[name.to_sym]
end

#[]=(name, value) ⇒ Object



20
21
22
# File 'lib/rust-tests.rb', line 20

def []=(name, value)
    @statistics[name.to_sym] = value
end

#adjusted_pvalue(method = 'bonferroni') ⇒ Object



24
25
26
27
# File 'lib/rust-tests.rb', line 24

def adjusted_pvalue(method='bonferroni')
    return 1 unless @hypothesis
    @hypothesis.adjusted_pvalue_for(self, method)
end

#significantObject



34
35
36
# File 'lib/rust-tests.rb', line 34

def significant
    pvalue < alpha
end

#to_sObject



38
39
40
41
42
43
# File 'lib/rust-tests.rb', line 38

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