Sha256: 928219e20632c9dc6ac36b5f870fb0b2886829658b1d1dced6040bbf2d62a13f
Contents?: true
Size: 1.58 KB
Versions: 6
Compression:
Stored size: 1.58 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') include Fathom describe DiscreteNode do before do @dn = DiscreteNode.new(:labels => [1,2,3]) end it "should assign :true and :false for labels, if none are provided" do lambda{@dn = DiscreteNode.new}.should_not raise_error @dn.labels.should eql([:true, :false]) end it "should create an array from a single value for its labels" do dn = DiscreteNode.new(:labels => 1) dn.labels.should eql([1]) end it "should take the values and convert them to labels, if there are no labels provided" do dn = DiscreteNode.new(:values => [1,2,3]) dn.labels.should eql([1,2,3]) end it "should create a unique list of labels" do dn = DiscreteNode.new(:labels => [1,1,2,3,1]) dn.labels.should eql([1,2,3]) end it "should expose the size of the labels" do @dn.size.should eql(3) end it "should alias length for size" do @dn.length.should eql(3) end it "should have a default distribution of DiscreteUniform" do @dn.distribution.should eql(Fathom::Distributions::DiscreteUniform) end it "should be able to produce a random variable from the discrete distribution" do @dn = DiscreteNode.new(:labels => [1,2]) # 9.31322574615479e-10 chance of failing 30.times.map {@dn.rand}.uniq.sort.should eql([1,2]) end it "should offer a uniform likelihood" do @dn.likelihood(:anything).to_a.should eql([1.0, 1.0, 1.0]) end it "should offer an alias of l for likelihood" do @dn.l(:anything).to_a.should eql([1.0, 1.0, 1.0]) end end
Version data entries
6 entries across 6 versions & 1 rubygems