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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59915309cb7225c37c317e61bc1a7de751857336315ee50a3615564c952a9093
4
- data.tar.gz: 3406685ce78de34fd11deb0042d8dcdc132b5fac6590f0f4cdc862c6f580470b
3
+ metadata.gz: '039d2242ba18c2406e01656ce3fef7579326cd72952f5b3124bfd70ab2c08e8f'
4
+ data.tar.gz: 66504f38eb6500ee2e86162c5c69ed59295537c500af5facab9a4175f63b187b
5
5
  SHA512:
6
- metadata.gz: df94327d2fd1607a645d93371d94b8ce37bb530c5b0ef90e1e29e3707c5add4100106505fac7ed48088760075bb6f7c29d062eae08196a9f965a6b23cdcba29c
7
- data.tar.gz: 2104f42d6007eb72806405d7cae0c26c4a44936a21d6055ff014a3cd39708e6c093db9dd1ae2aa88cc3a3c7470d0bb4ab3d01155d2dc2a07adc3d2c998bee35a
6
+ metadata.gz: 568092f5681af0f3370705b1308f5d6596931b95ef464ff3a699a60333ab88d84de8b31dd4d648bd32e6d3f00f26a6629c1bdbed0529f58fb301a5f6305985ea
7
+ data.tar.gz: 65f460722a4b1bc5dce715ccff4aed2eb65c94b8f7f2e99343a3117a5811779e130fe937a8161cf54b59bde3d32006321deb1ae8cf724aadcea8232b25e4d138
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem 'parallel'
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ montecarlo-rb (0.0.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ parallel (1.26.3)
10
+
11
+ PLATFORMS
12
+ arm64-darwin-23
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ montecarlo-rb!
17
+ parallel
18
+
19
+ BUNDLED WITH
20
+ 2.5.17
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 'monte_carlo_rb'
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 monte_carlo_rb
26
+ gem install montecarlo-rb
27
27
  ```
28
28
 
29
29
  ## Usage
@@ -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 = 10_000)
8
- result_counts = Hash.new(0)
9
- n_times.times do
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
- result_counts
13
+
14
+ picks.group_by { |pick| pick }.transform_values(&:size)
14
15
  end
15
16
  end
16
17
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "montecarlo-rb"
3
- s.version = "0.0.3"
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.3
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-20 00:00:00.000000000 Z
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