README.md in monte_carlo-0.0.6 vs README.md in monte_carlo-0.0.7
- old
+ new
@@ -19,10 +19,11 @@
$ gem install monte_carlo
## Usage
Every `MonteCarlo::Experiment` must have a sample method to generate random samples. The samples generated when the experiment is run will be collected into a `MonteCarlo::ExperimentResults` object after an optional computation method to turn the random sample into a meaningful value.
+
For example, the sample method may draw a random number between 1 and 10 and the computation method will test whether the number is greater than 5, returning `true` or `false` results.
```ruby
# Create an instance and configure it with the DSL
experiment = MonteCarlo::Experiment.new do
@@ -36,9 +37,17 @@
results.probability_distribution
# => {true=>0.499443, false=>0.500557}
```
Or run it with the shorthand class method syntax:
+
+```ruby
+# Use one method for both sample and computation and run immediately
+results = MonteCarlo::Experiment.run(1000000) do
+ sample = rand(10)
+ sample >= 5
+end
+```
## Docs
[Can be found here](http://www.rubydoc.info/gems/monte_carlo)