montecarlo-rb 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/README.md +2 -2
- data/lib/montecarlo/simulator.rb +7 -6
- data/montecarlo-rb.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '039d2242ba18c2406e01656ce3fef7579326cd72952f5b3124bfd70ab2c08e8f'
|
4
|
+
data.tar.gz: 66504f38eb6500ee2e86162c5c69ed59295537c500af5facab9a4175f63b187b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 568092f5681af0f3370705b1308f5d6596931b95ef464ff3a699a60333ab88d84de8b31dd4d648bd32e6d3f00f26a6629c1bdbed0529f58fb301a5f6305985ea
|
7
|
+
data.tar.gz: 65f460722a4b1bc5dce715ccff4aed2eb65c94b8f7f2e99343a3117a5811779e130fe937a8161cf54b59bde3d32006321deb1ae8cf724aadcea8232b25e4d138
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Installation
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem '
|
14
|
+
gem 'montecarlo-rb'
|
15
15
|
```
|
16
16
|
|
17
17
|
And then execute:
|
@@ -23,7 +23,7 @@ bundle install
|
|
23
23
|
Or install it yourself as:
|
24
24
|
|
25
25
|
```ruby
|
26
|
-
gem install
|
26
|
+
gem install montecarlo-rb
|
27
27
|
```
|
28
28
|
|
29
29
|
## Usage
|
data/lib/montecarlo/simulator.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
+
require 'parallel'
|
2
|
+
|
1
3
|
module MonteCarlo
|
2
4
|
class Simulator
|
3
5
|
def initialize(picker)
|
4
6
|
@picker = picker
|
5
7
|
end
|
6
8
|
|
7
|
-
def run(n_times =
|
8
|
-
|
9
|
-
|
10
|
-
result = @picker.pick
|
11
|
-
result_counts[result] += 1
|
9
|
+
def run(n_times = 1_000_000, threads = 1_000)
|
10
|
+
picks = Parallel.map(1..n_times, in_threads: threads) do
|
11
|
+
@picker.pick
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
picks.group_by { |pick| pick }.transform_values(&:size)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
data/montecarlo-rb.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "montecarlo-rb"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.4"
|
4
4
|
s.required_ruby_version = ">= 2.0.0"
|
5
5
|
s.summary = "MonteCarloRB is a Ruby library designed to perform Monte Carlo simulations based on historical data distributions."
|
6
6
|
s.description = "MonteCarloRB is a Ruby library designed to perform Monte Carlo simulations based on historical data distributions."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: montecarlo-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jiazhen Xie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: MonteCarloRB is a Ruby library designed to perform Monte Carlo simulations
|
14
14
|
based on historical data distributions.
|
@@ -19,6 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- ".gitignore"
|
21
21
|
- ".ruby-version"
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
22
24
|
- README.md
|
23
25
|
- Rakefile
|
24
26
|
- lib/montecarlo.rb
|