RandomBell is Ruby gem to generate normal(Gaussian) random number.
Add this line to your application's Gemfile:
gem 'random_bell'
And then execute:
$ bundle
Or install it yourself as:
$ gem install random_bell
bell = RandomBell.new
bell.rand #=> 0.596308234257563
bell.rand #=> 0.4986734346841275
bell.rand #=> 0.6441978387725272
+0.050: ***
+0.100: *****
+0.150: *********
+0.200: *************
+0.250: **********************
+0.300: **************************
+0.350: **********************************
+0.400: ****************************************
+0.450: ***********************************************
+0.500: *************************************************
+0.550: *************************************************
+0.600: ***********************************************
+0.650: **************************************
+0.700: **********************************
+0.750: **************************
+0.800: *********************
+0.850: *************
+0.900: ********
+0.950: *****
+1.000: ***
bell = RandomBell.new(mu: 0.75)
bell.rand
+0.050:
+0.100:
+0.150:
+0.200:
+0.250: *
+0.300: **
+0.350: *****
+0.400: *********
+0.450: *************
+0.500: ********************
+0.550: ***************************
+0.600: ***********************************
+0.650: ****************************************
+0.700: ************************************************
+0.750: *************************************************
+0.800: *************************************************
+0.850: ********************************************
+0.900: *******************************************
+0.950: ***********************************
+1.000: *************************
bell = RandomBell.new(sigma: 0.5)
bell.rand
+0.050: *******************************
+0.100: *********************************
+0.150: *********************************
+0.200: *************************************
+0.250: ******************************************
+0.300: ********************************************
+0.350: ***********************************************
+0.400: *********************************************
+0.450: *************************************************
+0.500: ***********************************************
+0.550: ************************************************
+0.600: ***********************************************
+0.650: ******************************************
+0.700: ********************************************
+0.750: *********************************************
+0.800: ******************************************
+0.850: ****************************************
+0.900: *****************************************
+0.950: *********************************
+1.000: **********************************
bell = RandomBell.new(range: 0.4..1.2)
bell.rand
+0.440: *********************************************
+0.480: *************************************************
+0.520: **************************************************
+0.560: *************************************************
+0.600: ********************************************
+0.640: *****************************************
+0.680: ***********************************
+0.720: *****************************
+0.760: ************************
+0.800: ********************
+0.840: *************
+0.880: **********
+0.920: *******
+0.960: ****
+1.000: ***
+1.040: *
+1.080: *
+1.120:
+1.160:
+1.200:
bell = RandomBell.new(mu: 25, sigma: 2, range: 20..30)
bell.rand
+20.500: **
+21.000: *****
+21.500: *********
+22.000: *************
+22.500: ********************
+23.000: *************************
+23.500: *********************************
+24.000: *************************************
+24.500: ********************************************
+25.000: ************************************************
+25.500: **********************************************
+26.000: *******************************************
+26.500: ****************************************
+27.000: ********************************
+27.500: *************************
+28.000: *******************
+28.500: ************
+29.000: *******
+29.500: *****
+30.000: **
RandomBell#to_histogram
returns primitive histogram string.
The histograms in this page are drawn by this method.
bell = RandomBell.new
puts bell.to_histogram
- Fork it ( https://github.com/s-osa/random_bell/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request