Sha256: a7da3065732e10cf65a9aada59409e60ef0675fbbcf85d6eea35be10d66d2848
Contents?: true
Size: 911 Bytes
Versions: 3
Compression:
Stored size: 911 Bytes
Contents
# encoding: UTF-8 require 'spec_helper' describe Similar do it "should not calculate pearson score when nothing to compare" do score = Similar.pearson_score([], []) score.should == 0 end it "should calculate pearson score" do a = [2.5, 3.5, 3.0, 3.5, 3.0, 2.5] b = [3.0, 3.5, 1.5, 5.0, 3.0, 3.5] score = Similar.pearson_score(a, b) score.should be_within(0.00001).of(0.39605901719066977) end it "should raise an exception when calculating pearson score with different array lengths" do a = [2.5, 3.5] b = [3.0] lambda { Similar.pearson_score(a, b) }.should raise_exception(ArgumentError, "Arrays not of equal length") end it "should calculate euclidean distance score" do a = 5.0, 5.0, 5.0, 5.0, 5.0 b = 4.0, 4.0, 4.0, 4.0, 4.0 score = Similar.euclidean_distance(a, b) score.should be_within(0.00001).of(0.16666666666666666) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
similar-0.0.5 | spec/similar_spec.rb |
similar-0.0.4 | spec/similar_spec.rb |
similar-0.0.3 | spec/similar_spec.rb |