Skip to content

Commit

Permalink
docs: add poisson method example
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshoku committed Nov 12, 2022
1 parent a01e475 commit 1b0c475
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ 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.bincount

Numo.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.
Expand Down

0 comments on commit 1b0c475

Please sign in to comment.