README.md in simple_stats-1.0.0 vs README.md in simple_stats-1.1.0
- old
+ new
@@ -75,11 +75,11 @@
# modes and frequencies return empty containers
[].modes # []
[].frequencies # {}
[].sorted_frequencies # []
-# if elements are preset, mean and median always return floats
+# if elements are present, mean and median always return floats
[1, 2, 3].mean # 2.0
[1, 2, 3].median # 2.0
[1, 2, 3, 4].mean # 2.5
[1, 2, 3, 4].median # 2.5
@@ -90,10 +90,34 @@
# but no guarantees on class here:
[2.0, 2, 1].modes # [2]
[2, 2.0, 1].modes # [2.0]
```
+## Mapping
+
+If the thing you want stats on is buried in your objects, you can pass a block to any SimpleStats method.
+
+```ruby
+# these two lines do the same thing
+cities.mean {|city| city.population}
+cities.map {|city| city.population}.mean
+
+# other examples
+cities.sum(&:public_school_count)
+cities.mean(&:public_school_count)
+cities.frequencies(&:professional_team_count)
+
+# more complicated examples
+cities.median {|city| city.municipal_income / city.schools.sum(&:students)}
+cities.map(&:schools).flatten.modes(&:team_name) # most common school sports team name
+cities.map(&:professional_teams).flatten.sorted_frequencies(&:kind) # number of different kinds of sports teams
+```
+
+## Interaction with other gems
+
+If any of SimpleStats' methods are already defined on Enumerable, SimpleStats _will not_ replace them with its own definition. In particular, ActiveSupport [defines a `sum` method](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/enumerable.rb). If both ActiveSupport and SimpleStats are used, the `sum` method will come from ActiveSupport. Don't worry, ActiveSupport and SimpleStats should work fine together.
+
## Help make it better!
Need something added? [Open an issue](https://github.com/brianhempel/simple_stats/issues). Or, even better, code it yourself and send a pull request:
# fork it on github, then clone:
@@ -104,6 +128,6 @@
git push
# then make a pull request
## License
-Public domain. (I, Brian Hempel, the original author release this code to the public domain.)
+Public domain. (I, Brian Hempel, the original author release this code to the public domain. February 10, 2012.)
\ No newline at end of file