From: Kenta Murata Date: 2010-08-03T13:45:26+09:00 Subject: [ruby-dev:41919] Re: [Feature #3647] Array#sample(n, replace=false) むらたです。 dev に英語で投稿してしまいました。ごめんなさい。 無理して英語で書いて投稿先を core にしていたと思っていたのですが・・・ On 2010/08/03, at 13:13, Kenta Murata wrote: > Feature #3647: Array#sample(n, replace=false) > http://redmine.ruby-lang.org/issues/show/3647 > > 起票者: Kenta Murata > ステータス: Open, 優先度: Normal > カテゴリ: core, Target version: 1.9.x > > Array#sample does not support sampling with replacement directly, so we must write codes like the following to obtain samples with replacement. > > samples_with_replacement = n.times.map { source.sample } > > If Array#sample has the argument for switching with/without replacement, we can write it as follow. > > samples_with_replacement = source.sample(n, true) この提案は、Array#sample メソッドで復元抽出もできるようにしたいという事です。 同様のインタフェースを持つ例として R の sample 関数があります。 -- Kenta Murata OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062 本を書きました!! 『Ruby 逆引きレシピ』 http://www.amazon.co.jp/dp/4798119881/mrkn-22 E-mail: mrkn@mrkn.jp twitter: http://twitter.com/mrkn/ blog: http://d.hatena.ne.jp/mrkn/