タグ

randomに関するkenkitiiのブックマーク (3)

  • Omegle

    “Of all tyrannies, a tyranny sincerely exercised for the good of its victims may be the most oppressive. It would be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end for they do so with the approval of their own

    Omegle
  • ランダムソート(笑)とは - 西尾泰和のはてなダイアリー

    誰が「ソートするときに比較関数に『ランダムに1か-1を返す関数』を与えたらシャッフルできる」って言い出したのかしらないけど、真に受ける方も真に受ける方だと思う。 たとえばソート関数が下のような「リストの先頭の値をピボットにしてそれより大きいものと小さいものに振り分けるクイックソート」だったとする。比較関数の所はランダムにしてある。 >>> def quicksort(xs): from random import random if len(xs) < 2: return xs pivot = xs[0] left = [] right = [] for x in xs[1:]: if random() < 0.5: left.append(x) else: right.append(x) return quicksort(left) + [pivot] + quicksort(right

    ランダムソート(笑)とは - 西尾泰和のはてなダイアリー
  • lucille development blog » Blog Archive » Xorshift RNGs

    G. Marsaglia. Xorshift RNGs. Journal of Statistical Software, 8(14) :1 6, 2003 http://www.jstatsoft.org/v08/i14/xorshift.pdf George Marsaglia 氏により 2003 年に考案された、xor とシフトを使うだけの超高速な擬似乱数生成器(Random Number Generator, RNG)です。周期は 2^k-1(k = 32, 64, 96, 128, 160, 192)。ランダム性のテストにも十分合格するとのこと。たとえば、周期が 2^128-1 の場合のルーチンは以下のようになり、乱数値の計算部分はわずか 1 行である。 unsigned long xor128(){ static unsigned long x=123456789,y

  • 1