るりまサーチ

最速Rubyリファレンスマニュアル検索!
192件ヒット [1-100件を表示] (0.033秒)
トップページ > クエリ:Raise[x] > クエリ:sample[x]

別のキーワード

  1. _builtin raise
  2. kernel raise
  3. fiber raise
  4. thread raise
  5. e2mmap raise

ライブラリ

クラス

モジュール

検索結果

<< 1 2 > >>

Array#sample -> object | nil (18140.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...@raise TypeError 引数 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 SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(random: SecureRandom)...

Array#sample(n) -> Array (18140.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...@raise TypeError 引数 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 SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(random: SecureRandom)...

Array#sample(n, random: Random) -> Array (18140.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...@raise TypeError 引数 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 SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(random: SecureRandom)...

Array#sample(random: Random) -> object | nil (18140.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。

...@raise TypeError 引数 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 SecureRandom などの乱数生成器を渡すことができます。

//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(random: SecureRandom)...

Rake::TaskManager#synthesize_file_task(task_name) -> Rake::FileTask | nil (30.0)

与えられたタスク名をもとにファイルタスクを合成します。

...す。

@raise RuntimeError タスクを合成できなかった場合に発生します。

//emlist[][ruby]{
# Rakefile での記載例とする

task default: :test_rake_app

task :test_rake_app do |task|
task.application.synthesize_file_task("sample_file") # => nil
IO.write("sample_file", ""...
...)
task.application.synthesize_file_task("sample_file") # => <Rake::FileTask sample_file => []>
end
//}...

絞り込み条件を変える

NEWS for Ruby 2.0.0 (24.0)

NEWS for Ruby 2.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...のメソッドに対応します

* Array
* 追加: Array#bsearch 二分探索します
* 非互換:
* Array#shuffle! と Array#sample の random パラメータには最大値のみを指定することが可能になりました
* Array#values_at に Range オブジェクト...
...m

* openssl
* Consistently raise an error when trying to encode nil values. All instances
of OpenSSL::ASN1::Primitive now raise TypeError when calling to_der on an
instance whose value is nil. All instances of OpenSSL::ASN1::Constructive
raise
NoMethodError in the same case....

Random#rand -> Float (24.0)

一様な擬似乱数を発生させます。

...
range.begin + 数値 が適切な値を返す必要があります。

@raise Errno::EDOM rand(1..Float::INFINITY) などのように範囲に問題があるときに発生します。
@raise ArgumentError 引数の数が0または1では無い時、引数に負の数値を与えた...
...うに見える

# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}


@see Kernel.#r...

Random#rand(max) -> Integer | Float (24.0)

一様な擬似乱数を発生させます。

...
range.begin + 数値 が適切な値を返す必要があります。

@raise Errno::EDOM rand(1..Float::INFINITY) などのように範囲に問題があるときに発生します。
@raise ArgumentError 引数の数が0または1では無い時、引数に負の数値を与えた...
...うに見える

# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}


@see Kernel.#r...

Random#rand(range) -> Integer | Float (24.0)

一様な擬似乱数を発生させます。

...
range.begin + 数値 が適切な値を返す必要があります。

@raise Errno::EDOM rand(1..Float::INFINITY) などのように範囲に問題があるときに発生します。
@raise ArgumentError 引数の数が0または1では無い時、引数に負の数値を与えた...
...うに見える

# 上と同じ種で再初期化
prng = Random.new(1234)
srand(1234)
# Kernel.#rand は Array#sample などの影響を受けて値がずれることがある
[0, 1].sample
prng.rand #=> 0.1915194503788923
rand #=> 0.6221087710398319
//}


@see Kernel.#r...
<< 1 2 > >>