é¡ä¼¼gemã¨ãã¦ã¯ ActiveRecordç¨ã®weighted_random {value => weight} å½¢å¼ã®Hashã使ã weighted_randomizer ã¨ããã®ããã£ããã©ãå½æ¹ã®ã¦ã¼ã¹ã±ã¼ã¹ã«ã¯åããªãã£ãã®ã§èªä½ããã weighted_sample $ gem install weighted_sampleã§å ¥ãã¾ãã require 'weighted_sample' [1, 9, 90].weighted_sample_by {|x| x} # => 1(1%), 9(9%), 90(90%) ä»»æã®Enumerableã§ä½¿ãããã©ãå é¨çã«2åeachãã¦ãã®ã§ãçæãã ããã éã¿ã«ä½¿ããã®ã¯ãä»ã®ã¨ããæ´æ°ã®ã¿ã§ã(è¦æãããã°Floatã«ã対å¿ããããããªãã㪠or ãã«ãªã¯ãã)ã
{{#tags}}- {{label}}
{{/tags}}