Generate Array of Numbers that fit to a Probability Distribution in Ruby?

后端 未结 4 2047
青春惊慌失措
青春惊慌失措 2021-01-03 11:58

Say I have 100 records, and I want to mock out the created_at date so it fits on some curve. Is there a library to do that, or what formula could I use? I thi

4条回答
  •  再見小時候
    2021-01-03 12:43

    Another option is the Distribution gem under SciRuby. You can generate normal numbers by:

    require 'distribution'
    
    rng = Distribution::Normal.rng
    random_numbers = Array.new(100).map { rng.call }
    

    There are RNGs for various other distributions as well.

提交回复
热议问题