math_probability 0.2.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 126b15b6b5d89b948f88d15ed649551fca41dd58
4
- data.tar.gz: a6cbc805e89281180ccd401ed840c6652adf11be
3
+ metadata.gz: 6f9663665c75fb9d29ec90847b892da061f61130
4
+ data.tar.gz: 5daae246f7c6550558993a7ba15bc82db6853371
5
5
  SHA512:
6
- metadata.gz: 8aaf432baa59badd5b8e441aafdbae9bf24e88ef1724c332d008601e9fdac24e993bacfdd904e52db183638fa2df437d7a5c5eb8415890f6a0eb05c84d848452
7
- data.tar.gz: b5ec7a3931ec40893e0c0ddb64b519b4d2d34970132317a6b875cc9eeb10c05235e2fd39686c670e5dfbbfe4535b5ec596fc20cb00f33b361e43e2ab2f8f70a7
6
+ metadata.gz: c1dbba8ab53c0463e905d396791cd319de513f0cb630f163b92551ede0ec096a070cd0fb9b91765cc0e32c1fbcc039563dfef632c7c696892aa69abc9f794089
7
+ data.tar.gz: 70208f2b091d28c8478b8cd16ef21ee1756380d18df45db99d941acd6ad14bcaaed996fc60fca5444d36386ce3bbc6c7b0f561f07d236dcbaa7619bb31941873
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/polysaturate/math_probability/badge.png?branch=master)](https://coveralls.io/r/polysaturate/math_probability?branch=master)
5
5
  [![Code Climate](https://codeclimate.com/github/polysaturate/math_probability.png)](https://codeclimate.com/github/polysaturate/math_probability)
6
6
 
7
- Quickly find factorals, summnations, permutations, combanations and probability answers
7
+ Quickly find factorals, summations, permutations, combanations and probability answers
8
8
 
9
9
  ## Installation
10
10
 
@@ -47,11 +47,20 @@ Combinations | Usage combinations(objects, at_a_time)
47
47
  prob.combinations(10,4)
48
48
  => 210
49
49
 
50
- Probability | Usage probability(choices, outcomes)
50
+ Probability | Usage probability(choices, outcomes, reduce=true)
51
51
 
52
52
  prob.probability(1,4)
53
- => [0.25, "25.0%", "1/4"]
53
+ => {:decimal=> 0.25, :percentage=>"25.0%", :fraction=>"1/4"}
54
+ prob.probability(2,4)
55
+ => {:decimal=> 0.5, :percentage=>"50.0%", :fraction=>"1/2"}
56
+ prob.probability(2,4,false)
57
+ => {:decimal=> 0.5, :percentage=>"50.0%", :fraction=>"2/4"}
54
58
 
59
+ ## Running tests
60
+
61
+ $ git clone git://github.com/polysaturate/math_probability.git
62
+ $ bundle install
63
+ $ rake
55
64
 
56
65
  ## Contributing
57
66
 
@@ -28,9 +28,8 @@ module MathProbability
28
28
  end
29
29
 
30
30
  def self.probability(choices, outcomes, reduce=true)
31
- answer ||= []
32
31
  a = choices.to_f / outcomes
33
- answer << a << "#{a*100}%" << (reduce ? reduced_fraction(choices, outcomes) : "#{choices}/#{outcomes}")
32
+ answer = {decimal: a, percentage: "#{a*100}%", fraction: (reduce ? reduced_fraction(choices, outcomes) : "#{choices}/#{outcomes}")}
34
33
  end
35
34
 
36
35
  private
@@ -1,3 +1,3 @@
1
1
  module MathProbability
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -29,15 +29,15 @@ describe MathProbability::Probability do
29
29
  end
30
30
 
31
31
  it "should return all forms of Probability" do
32
- subject.probability(1,2).must_equal([0.5, "50.0%", "1/2"])
32
+ subject.probability(1,2).must_equal({:decimal=> 0.5, :percentage=>"50.0%", :fraction=>"1/2"})
33
33
  end
34
34
 
35
35
  it "should return a reduced fraction" do
36
- subject.probability(2,4).must_equal([0.5, "50.0%", "1/2"])
36
+ subject.probability(2,4).must_equal({:decimal=> 0.5, :percentage=>"50.0%", :fraction=>"1/2"})
37
37
  end
38
38
 
39
39
  it "should not return a reduced fraction if flag is set to false" do
40
- subject.probability(2,4,false).must_equal([0.5, "50.0%", "2/4"])
40
+ subject.probability(2,4,false).must_equal({:decimal=> 0.5, :percentage=>"50.0%", :fraction=>"2/4"})
41
41
  end
42
42
 
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: math_probability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Race
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2013-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler