77件ヒット
[1-77件を表示]
(0.044秒)
別のキーワード
検索結果
先頭5件
-
Array
# sample(n) -> Array (27226.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}... -
Array
# sample(n , random: Random) -> Array (27226.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}... -
Array
# sample -> object | nil (27126.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}... -
Array
# sample(random: Random) -> object | nil (27126.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...した場合に発生します。
@raise ArgumentError 引数 n に負の数を指定した場合に発生します。
//emlist[例][ruby]{
a = (1..10).to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}... -
Random
# rand -> Float (20.0) -
一様な擬似乱数を発生させます。
...ように見える
# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}
@see Kernel... -
Random
# rand(max) -> Integer | Float (20.0) -
一様な擬似乱数を発生させます。
...ように見える
# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}
@see Kernel... -
Random
# rand(range) -> Integer | Float (20.0) -
一様な擬似乱数を発生させます。
...ように見える
# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}
@see Kernel...