Linear Regression Trend Calculator
This is a simple gem to help calculate linear regression trendlines for a given list of samples.
Note
This gem was created using this gist. originally authored by Scott Baldwin.. Thanks dude.
Installation
Add this line to your application's Gemfile:
gem 'linear_regression_trend'
And then execute:
$ bundle
Or install it yourself as:
$ gem install linear_regression_trend
Usage
my_array_of_samples = [10, 14, 18, 22, 26]
trender = LinearRegressionTrend::Calculator.new(my_array_of_samples)
trended_samples = trender.trend # => [array of trend points]
trend_slope = trender.slope # => 4
trend_intercept = trender.intercept # => 6
Development
Check out the tests in the /spec dir, and also install iRuby notebook, and take a look at the live documentation in /doc.
Contributing
- Fork it ( https://github.com/zero-one-software/linear_regression_trend/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Add some tests
- Create a new Pull Request
- Do a happy dance