Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yoshoku/numo-random
Numo::Random provides random number generation with several distributions for Numo::NArray.
https://github.com/yoshoku/numo-random
gem random ruby statistics
Last synced: 3 months ago
JSON representation
Numo::Random provides random number generation with several distributions for Numo::NArray.
- Host: GitHub
- URL: https://github.com/yoshoku/numo-random
- Owner: yoshoku
- License: apache-2.0
- Created: 2022-09-17T22:15:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-01T12:07:23.000Z (about 1 year ago)
- Last Synced: 2024-10-10T15:51:30.309Z (4 months ago)
- Topics: gem, random, ruby, statistics
- Language: Ruby
- Homepage: https://rubygems.org/gems/numo-random
- Size: 166 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Numo::Random
[![Build Status](https://github.com/yoshoku/numo-random/actions/workflows/main.yml/badge.svg)](https://github.com/yoshoku/numo-random/actions/workflows/main.yml)
[![Gem Version](https://badge.fury.io/rb/numo-random.svg)](https://badge.fury.io/rb/numo-random)
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://github.com/yoshoku/numo-random/blob/main/LICENSE.txt)
[![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/numo-random/doc/)Numo::Random provides random number generation with several distributions for Numo::NArray.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'numo-random'
```And then execute:
$ bundle install
Or install it yourself as:
$ gem install numo-random
## Usage
An example of generating random numbers according to the standard normal distribution:
```ruby
require 'numo/narray'
require 'numo/gnuplot'require 'numo/random'
# Creating random number generator.
rng = Numo::Random::Generator.new(seed: 42)# Generating random numbers with a normal distribution.
x = rng.normal(shape: [5000, 2], loc: 0.0, scale: 1.0)# Plotting the generated result.
Numo.gnuplot do
set(terminal: 'png')
set(output: 'normal2d.png')
plot(x[true, 0], x[true, 1])
end
```![normal2d.png](https://user-images.githubusercontent.com/5562409/197376738-ee8d2b12-1902-4a12-bcf3-757461f2f2db.png)
An example of generating random numbers according to the Poisson distribution:
```ruby
require 'numo/narray'
require 'numo/gnuplot'require 'numo/random'
# Creating random number generator.
rng = Numo::Random::Generator.new(seed: 9)# Generating random numbers with Poisson distribution.
x = rng.poisson(shape: 10000, mean: 12)# Plotting the generated result.
h = x.bincountNumo.gnuplot do
set(terminal: 'png')
set(output: 'poisson2d.png')
plot(h, with: 'boxes')
end
```![poisson2d.png](https://user-images.githubusercontent.com/5562409/201478863-61d31eb8-7c0b-4406-b255-fff29187a16a.png)
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/numo-random.
This project is intended to be a safe, welcoming space for collaboration,
and contributors are expected to adhere to the [code of conduct](https://github.com/yoshoku/numo-random/blob/main/CODE_OF_CONDUCT.md).## License
The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).