るりまサーチ

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

別のキーワード

  1. string b
  2. _builtin b
  3. b string
  4. b
  5. b _builtin

検索結果

<< 1 2 3 ... > >>

bigdecimal/ludcmp (26022.0)

LU 分解を用いて、連立1次方程式 Ax = b の解 x を求める機能を提供します。

...LU 分解を用いて、連立1次方程式 Ax = b の解 x を求める機能を提供します。

Ruby のソースコード中の以下のサンプルスクリプトも参考にしてください。

* https://github.com/ruby/ruby/blob/master/ext/bigdecimal/sample/linear.rb...

bigdecimal/newton (26012.0)

ニュートン法を用いて非線形方程式 f(x) = 0 の解 x を求める機能を提供しま す。

...非線形方程式 f(x) = 0 の解 x を求める機能を提供しま
す。

本サブライブラリは BigDecimal に依存しません。

実行例:

require "bigdecimal"
require "bigdecimal/newton"

...

n = Newton.nlsolve(f, x)

引数 f には関数を表すオブジェクトを指...
....eps

収束の基準になる epsilon 値を返します。2 つの値が異なる値かどうかを比
較するのに使用されます。|a - b| < f.eps となる 2 つの値は同じ値である
とみなされます。

引数 x には探索を開始する点を数値の配列で指定...
...変更されます。x から解を取得します。

戻り値 n は計算した回数を整数で返します。

Ruby のソースコード中の以下のサンプルスクリプトも参考にしてください。

* https://github.com/ruby/ruby/blob/master/ext/bigdecimal/sample/nlsolve.rb...

Array#sample -> object | nil (18228.0)

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で 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 'securer...
...andom'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
//}...

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

配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で 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 'securer...
...andom'
a = (1..10).to_a
p a.sample(random: SecureRandom) #=> 2
//}...

Proc#binding -> Binding (6212.0)

Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。

...Proc オブジェクトが保持するコンテキストを
B
inding オブジェクトで返します。

//emlist[例][ruby]{
def fred(param)
proc {}
end

sample
_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}...

絞り込み条件を変える

RakeFileUtils.verbose_flag -> bool (6212.0)

この値が真の場合、詳細を表示します。

...この値が真の場合、詳細を表示します。

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

task default: :sample_file_task

file :sample_file_task do |t|
# --verbose で rake を実行する
RakeFileUtils.verbose_flag # => true
end
//}...

Kernel$$INPUT_LINE_NUMBER -> Integer (6112.0)

$. の別名

...$. の別名

1 e
2 f
3 g
4 h
5 i
# end of a.txt

require "English"

File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb

ruby sample.rb a.txt
#=> 5...

RakeFileUtils.verbose_flag=(flag) (6112.0)

詳細を表示するかどうか設定します。

...します。


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

task default: :sample_file_task

file :sample_file_task do |t|
# --verbose で rake を実行する
p RakeFileUtils.verbose_flag # => true
RakeFileUtils.verbose_flag = false
p RakeFileUtils.verbose_flag # => false
end
//}...

Kernel.#abort -> () (6106.0)

Ruby プログラムをエラーメッセージ付きで終了します。終了ステータスは 1 固定です。

...Ruby プログラムをエラーメッセージ付きで終了します。終了ステータスは 1 固定です。

このメソッドと Kernel.#exit との違いは、プログラムの終了ステー
タスが 1 (正確にはCレベルの定数 EXIT_FAILURE の値)固定であることと、...
...エラーメッセージ文字列です。

//emlist[][ruby]{
puts 'start'
b
egin
puts 'start1...'
abort "error1"
rescue SystemExit => err
puts "end1 with #{err.inspect}"
end

b
egin
puts 'start2...'
raise RuntimeError.new
rescue
abort
ensure
puts 'end2...'
end
puts 'end' #実行され...
...#(標準出力)
#=> start
# start1...
# end1 with #<SystemExit: error1>
# start2...
# end2...
#終了ステータス:1
#(標準エラー出力)
#=> error1
# Traceback (most recent call last):
# sample.rb:11:in `<main>': RuntimeError (RuntimeError)
//}

@see Kernel.#exit,Kernel.#exit!...
<< 1 2 3 ... > >>