Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moving_average

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moving_average

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MovingAverage

This gem adds methods to the Array class to compute different types of moving averages.

Installation

Add this line to your application's Gemfile:

gem 'moving_average'

And then execute:

$ bundle

Or install it yourself as:

$ gem install moving_average

Usage

To compute a simple moving average (SMA), you can use

a = [1, 2, 3, 4, 5]
a.simple_moving_average => 3

or

a.sma => 3

You could also find the SMA of the 3-element slice [1, 2, 3] of the Array using

a.sma(2, 3) => 2

or the 4-element slice [1, 2, 3, 4] by using

a.sma(3, 4) => 2.5

An exponential moving average (EMA), a smoothed moving average (SMMA), and a weighted moving average (WMA) may be computed in the same way.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 24 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc