class Rust::StatisticalTests::Hypothesis

Attributes

results[R]
title[R]

Public Class Methods

find(title_or_instance) click to toggle source
# File lib/rust-tests.rb, line 47
def self.find(title_or_instance)
    return Hypothesis.new(nil) if title_or_instance == nil
    
    if title_or_instance.is_a?(String)
        ObjectSpace.each_object(Hypothesis) do |instance|
            return instance if instance.title == title_or_instance
        end
        
        return Hypothesis.new(title_or_instance)
    elsif title_or_instance.is_a?(Hypothesis)
        return title_or_instance
    end
    
    raise TypeError, "Expected nil, String or Hypothesis"
end
new(title) click to toggle source
# File lib/rust-tests.rb, line 66
def initialize(title)
    @title = title
    @results = []
end

Public Instance Methods

add(result) click to toggle source
# File lib/rust-tests.rb, line 71
def add(result)            
    @results << result
end
adjusted_pvalue_for(instance, method) click to toggle source
# File lib/rust-tests.rb, line 75
def adjusted_pvalue_for(instance, method)
    p_values = @results.map { |r| r.pvalue }
    index = @results.index(instance)
    
    adjusted_pvalues = Rust::StatisticalTests::PValueAdjustment.method(method).adjust(*p_values)
    
    if adjusted_pvalues.is_a?(Numeric)
        return adjusted_pvalues
    else
        return adjusted_pvalues[index]
    end
end