[前][次][番号順一覧][スレッド一覧]

ruby-changes:43882

From: nobu <ko1@a...>
Date: Thu, 18 Aug 2016 12:19:30 +0900 (JST)
Subject: [ruby-changes:43882] nobu:r55955 (trunk): test_rand.rb: refine probability test

nobu	2016-08-18 12:19:24 +0900 (Thu, 18 Aug 2016)

  New Revision: 55955

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55955

  Log:
    test_rand.rb: refine probability test
    
    * test/ruby/test_rand.rb (test_new_seed): refine probability of
      failure from 1/256 to 1/256**8.

  Modified files:
    trunk/test/ruby/test_rand.rb
Index: test/ruby/test_rand.rb
===================================================================
--- test/ruby/test_rand.rb	(revision 55954)
+++ test/ruby/test_rand.rb	(revision 55955)
@@ -559,8 +559,14 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rand.rb#L559
   end
 
   def test_new_seed
-    v = Random.new_seed
-    assert_kind_of(Integer, v)
-    assert_operator(v.size, :>=, 16)
+    size = 0
+    n = 8
+    n.times do
+      v = Random.new_seed
+      assert_kind_of(Integer, v)
+      size += v.size
+    end
+    # probability of failure <= 1/256**8
+    assert_operator(size.fdiv(n), :>, 15)
   end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]