class Prolly::Ps
Public Class Methods
add(datum)
click to toggle source
# File lib/prolly/ps.rb, line 24 def add(datum) ps.add(datum) end
combo(list_of_vals)
click to toggle source
# File lib/prolly/ps.rb, line 46 def combo(list_of_vals) if list_of_vals.length == 1 list_of_vals.first.map { |e| [e] } else combinations = combo(list_of_vals[1..-1]) list_of_vals.first.flat_map { |val| combinations.map { |e| [val] + e } } end end
import(data)
click to toggle source
# File lib/prolly/ps.rb, line 16 def import(data) ps.import(data) end
new(storage = nil)
click to toggle source
# File lib/prolly/ps.rb, line 63 def initialize(storage = nil) #@storage = Storage::Mongodb.new() @storage = Storage::Rubylist.new() #@storage = Storage::Redis.new() end
ps()
click to toggle source
# File lib/prolly/ps.rb, line 12 def ps @ps ||= Ps.new end
reset()
click to toggle source
# File lib/prolly/ps.rb, line 20 def reset ps.reset end
rv(*rand_vars)
click to toggle source
# File lib/prolly/ps.rb, line 28 def rv(*rand_vars) if rand_vars.empty? ps.rand_vars else RandVar.new(ps, *rand_vars) end end
stash()
click to toggle source
# File lib/prolly/ps.rb, line 36 def stash ps.stash end
uniq_vals(uspec_rvs)
click to toggle source
unique values for a random variable.
If there are multiple random variables, then we get combinations of the unique values of the random variables
# File lib/prolly/ps.rb, line 44 def uniq_vals(uspec_rvs) def combo(list_of_vals) if list_of_vals.length == 1 list_of_vals.first.map { |e| [e] } else combinations = combo(list_of_vals[1..-1]) list_of_vals.first.flat_map { |val| combinations.map { |e| [val] + e } } end end combo(uspec_rvs.map { |uspec_rv| @ps.uniq_vals(uspec_rv) }) end