class Statsample::Reliability::ItemCharacteristicCurve
Attributes
counts[R]
totals[R]
vector_total[R]
Public Class Methods
new(ds, vector_total=nil)
click to toggle source
# File lib/statsample/reliability.rb, line 112 def initialize (ds, vector_total=nil) vector_total||=ds.vector_sum raise ArgumentError, "Total size != Dataset size" if vector_total.size!=ds.cases @vector_total=vector_total @ds=ds @totals={} @counts=@ds.fields.inject({}) {|a,v| a[v]={};a} process end
Public Instance Methods
curve_field(field, item)
click to toggle source
Return a hash with p for each different value on a vector
# File lib/statsample/reliability.rb, line 137 def curve_field(field, item) out={} item=item.to_s @totals.each do |value,n| count_value= @counts[field][value][item].nil? ? 0 : @counts[field][value][item] out[value]=count_value.quo(n) end out end
process()
click to toggle source
# File lib/statsample/reliability.rb, line 121 def process i=0 @ds.each do |row| tot=@vector_total[i] @totals[tot]||=0 @totals[tot]+=1 @ds.fields.each do |f| item=row[f].to_s @counts[f][tot]||={} @counts[f][tot][item]||=0 @counts[f][tot][item] += 1 end i+=1 end end