split_cat 0.0.8 → 0.0.9

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: 452394b6cefb9d8e96ba04e3cbc6cb611244004e
4
- data.tar.gz: cd630adea48b74ad271697ecee59028b275085d1
3
+ metadata.gz: 7421cdc1eda7110d22fe222b5b4ff9d7ca1ec037
4
+ data.tar.gz: 3ed2852232cef62c121ca812942f6e567bafe26b
5
5
  SHA512:
6
- metadata.gz: 9e170f44d7edcf458da422e559692f12ba16908a6d593c3f43b8a943c9fc888ac95f42671c29f38f6553f35ed03cc0001ed59f8355d3adbdd5704f164d9fb48c
7
- data.tar.gz: 458039df700130278f2ee88731f8342f8984d8976f8432cafa8714f60cfbb9872cf6e6f12f6841887d4f24f7a0ae65f60cb47121eafa849457cdaf33c850815f
6
+ metadata.gz: 1044cfae67cd1251fa899a6cfe7b102ee7adb08c760ed76d8b1775d0ab0ccfb5db353083a341b31a426e14f9ffbc758ac25a48e836e89eed052f3ae11e524644
7
+ data.tar.gz: cdbd49e89a8131acd3c6f103cafefd2d0bdbc910e8a963cde291564f94b116306d2555ac380d9a86ef7ced8cc63c64aaea00feed3d4e379b40fd78c0afbb723b
@@ -82,9 +82,15 @@ module SplitCat
82
82
 
83
83
  def choose_hypothesis
84
84
  total = 0
85
- roll = rand( total_weight ) + 1
86
- hypotheses.each { |h| return h if roll <= ( total += h.weight ) }
87
- return hypotheses.first
85
+ roll = Kernel.rand( total_weight ) + 1
86
+ hypothesis = nil
87
+ hypotheses.each do |h|
88
+ if roll <= ( total += h.weight )
89
+ hypothesis ||= h
90
+ end
91
+ end
92
+ hypothesis ||= hypotheses.first
93
+ return hypothesis
88
94
  end
89
95
 
90
96
  #############################################################################
@@ -1,3 +1,3 @@
1
1
  module SplitCat
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end