127件ヒット
[1-100件を表示]
(0.105秒)
種類
- インスタンスメソッド (77)
- モジュール関数 (39)
- ライブラリ (11)
ライブラリ
- ビルトイン (77)
- cmath (6)
- openssl (22)
-
rinda
/ tuplespace (11)
クラス
-
OpenSSL
:: BN (22) -
Rinda
:: TupleEntry (11)
モジュール
- CMath (6)
- Enumerable (44)
- Math (33)
検索結果
先頭5件
-
OpenSSL
:: BN # **(other) -> OpenSSL :: BN (21206.0) -
自身の other 乗を返します。
...自身の other 乗を返します。
@param other 指数
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::BN#mod_exp... -
OpenSSL
:: BN # mod _ exp(other , m) -> OpenSSL :: BN (9223.0) -
(self ** other) % m を返します。
...(self ** other) % m を返します。
//emlist[][ruby]{
require 'openssl'
OpenSSL::BN.new("7").mod_exp(OpenSSL::BN.new("3"), OpenSSL::BN.new("6")) # => 1
//}
@param other 指数
@param m 剰余を取る数
@raise OpenSSL::BNError 計算時エラー... -
Rinda
:: TupleEntry # expires -> Time (9106.0) -
タプルの期限切れの時刻を返します。
...タプルの期限切れの時刻を返します。
有効期限を無限に指定した場合、この時刻は Time.at(2**31-1)、つまり
Tue Jan 19 03:14:07 GMT Standard Time 2038 を返します。
@see Rinda::TupleEntry#expire... -
CMath
. # exp!(x) -> Float (6253.0) -
実数 x の指数関数(Math::E の x 乗)の値を返します。 Math.#exp のエイリアスです。
...す。
Math.#exp のエイリアスです。
@param x Math::E を x 乗する数を実数で指定します。
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{......require "cmath"
CMath.exp!(0) # => 1
CMath.exp!(0.5) # => Math.sqrt(Math::E)
CMath.exp!(1) # => Math::E
CMath.exp!(2) # => Math::E ** 2
//}
@see Math.#exp... -
Math
. # log(x) -> Float (6212.0) -
x の対数(logarithm)を返します。
...x の対数(logarithm)を返します。
引数 x, b の両方に 0 を指定した場合は Float::NAN を返します。
@param x 正の実数を指定します。
@param b 底を指定します。省略した場合は自然対数(natural logarithm)を計算します。
@raise TypeErr......らかに負の数を指定した場合に発生します。
//emlist[例][ruby]{
Math.log(0) # => -Infinity
Math.log(1) # => 0.0
Math.log(Math::E) # => 1.0
Math.log(Math::E**3) # => 3.0
Math.log(12, 3) # => 2.2618595071429146
//}
@see Math.#log2, Math.#log10, Math.#exp... -
Math
. # log(x , b) -> Float (6212.0) -
x の対数(logarithm)を返します。
...x の対数(logarithm)を返します。
引数 x, b の両方に 0 を指定した場合は Float::NAN を返します。
@param x 正の実数を指定します。
@param b 底を指定します。省略した場合は自然対数(natural logarithm)を計算します。
@raise TypeErr......らかに負の数を指定した場合に発生します。
//emlist[例][ruby]{
Math.log(0) # => -Infinity
Math.log(1) # => 0.0
Math.log(Math::E) # => 1.0
Math.log(Math::E**3) # => 3.0
Math.log(12, 3) # => 2.2618595071429146
//}
@see Math.#log2, Math.#log10, Math.#exp... -
Math
. # frexp(x) -> [Float , Integer] (6206.0) -
実数 x の仮数部と指数部の配列を返します。
...ypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
fraction, exponent = Math.frexp(1234) # => [0.6025390625, 11]
fraction * 2**exponent # => 1234.0
//}... -
bigdecimal (6042.0)
-
bigdecimal は浮動小数点数演算ライブラリです。 任意の精度で 10 進表現された浮動小数点数を扱えます。
...bigdecimal は浮動小数点数演算ライブラリです。
任意の精度で 10 進表現された浮動小数点数を扱えます。
//emlist[][ruby]{
require 'bigdecimal'
a = BigDecimal("0.123456789123456789")
b = BigDecimal("123456.78912345678", 40)
print a + b # => 0.123456912580245903456......造
BigDecimal内部で浮動小数点は構造体(Real)で表現されます。
そのうち仮数部は unsigned long の配列 (以下の構造体要素 frac) で管理されます。
概念的には、以下のようになります。
<浮動小数点数> = 0.xxxxxxxxx * BASE ** n
ここで......ned short flag; // 各種の制御フラッグ
int exponent; // 指数部の値(仮数部*BASE**exponent)
unsigned long frac[1]; // 仮数部の配列(可変)
} Real;
例えば BASE=10000 のとき 1234.56784321 という数字は、
0.1234 5678 4321*(10000)**1
です... -
Enumerable
# max _ by {|item| . . . } -> object | nil (3112.0) -
各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。
...しなければ nil を返します。
引数を指定する形式では、空の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと......ampleを使用します。][ruby]{
module Enumerable
# weighted random sampling.
#
# Pavlos S. Efraimidis, Paul G. Spirakis
# Weighted random sampling with a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (......yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p a.length #=> 20000
h = a.group_by {|x| x }
-10.upto(10) {|x| puts "*" * (h[x].length/30.0).to_i if h[x] }
#=> *
# ***
# ******
# ***********
#... -
Enumerable
# max _ by -> Enumerator (3012.0) -
各要素を順番にブロックに渡して実行し、 その評価結果を <=> で比較して、 最大であった値に対応する元の要素、もしくは最大の n 要素が降順で入った配列を返します。
...しなければ nil を返します。
引数を指定する形式では、空の配列を返します。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
Enumerable#max と Enumerable#max_by の
違いは Enumerable#sort と Enumerable#sort_by の違いと......ampleを使用します。][ruby]{
module Enumerable
# weighted random sampling.
#
# Pavlos S. Efraimidis, Paul G. Spirakis
# Weighted random sampling with a reservoir
# Information Processing Letters
# Volume 97, Issue 5 (16 March 2006)
def wsample(n)
self.max_by(n) {|v| rand ** (......yield(v)) }
end
end
e = (-20..20).to_a*10000
a = e.wsample(20000) {|x|
Math.exp(-(x/5.0)**2) # normal distribution
}
# a is 20000 samples from e.
p a.length #=> 20000
h = a.group_by {|x| x }
-10.upto(10) {|x| puts "*" * (h[x].length/30.0).to_i if h[x] }
#=> *
# ***
# ******
# ***********
#...