Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lockfile and start of rubocop #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: ./.rubocop_todo.yml
27 changes: 27 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-02-02 13:47:03 -0800 using RuboCop version 0.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
Metrics/AbcSize:
Max: 87

# Offense count: 8
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 109

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 26

# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 9
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
holtwinters
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.0
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- mode: ruby; -*-
source :rubygems
source 'https://rubygems.org'
gemspec
39 changes: 39 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PATH
remote: .
specs:
holt_winters (0.0.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.2.0)
diff-lcs (1.1.3)
parser (2.3.0.2)
ast (~> 2.2)
powerpack (0.1.1)
rainbow (2.1.0)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rubocop (0.36.0)
parser (>= 2.3.0.0, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
ruby-progressbar (1.7.5)

PLATFORMS
ruby

DEPENDENCIES
holt_winters!
rspec (~> 2.6.0)
rubocop

BUNDLED WITH
1.11.2
23 changes: 12 additions & 11 deletions holt_winters.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# -*- mode: ruby; encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "holt_winters/version"
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'holt_winters/version'

Gem::Specification.new do |s|
s.name = "holt_winters"
s.name = 'holt_winters'
s.version = HoltWinters::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Brandon Keene"]
s.email = ["[email protected]"]
s.homepage = ""
s.summary = %q{Holt-Winters Triple Exponential Smoothing}
s.authors = ['Brandon Keene']
s.email = ['[email protected]']
s.homepage = ''
s.summary = 'Holt-Winters Triple Exponential Smoothing'

s.rubyforge_project = "holt_winters"
s.rubyforge_project = 'holt_winters'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ['lib']

s.add_development_dependency "rspec", "~> 2.6.0"
s.add_development_dependency 'rspec', '~> 2.6.0'
s.add_development_dependency 'rubocop'
end
10 changes: 5 additions & 5 deletions lib/holt_winters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def forecast(y, alpha, beta, gamma, period, m)

seasonal = seasonal_indicies(y, period, seasons)

holt_winters(y, a0, b0, alpha, beta, gamma, seasonal, period, m);
holt_winters(y, a0, b0, alpha, beta, gamma, seasonal, period, m)
end

def holt_winters(y, a0, b0, alpha, beta, gamma, seasonal, period, m)
Expand All @@ -61,8 +61,10 @@ def holt_winters(y, a0, b0, alpha, beta, gamma, seasonal, period, m)

(2..(y.size - 1)).each do |i|
# Calculate overall smoothing
# rubocop:disable all
if (i - period) >= 0
st[i] = alpha * y[i] / it[i - period] + (1.0 - alpha) * (st[i - 1] + bt[i - 1])
# rubocop:enable all
st[i] = alpha * y[i] / it[i - period] + (1.0 - alpha) * (st[i - 1] + bt[i - 1])
else
st[i] = alpha * y[i] + (1.0 - alpha) * (st[i - 1] + bt[i - 1])
end
Expand All @@ -86,11 +88,10 @@ def holt_winters(y, a0, b0, alpha, beta, gamma, seasonal, period, m)

# See: http://robjhyndman.com/researchtips/hw-initialization/
# 1st period's average can be taken. But y[0] works better.
def initial_level(y, period)
def initial_level(y, _period)
y.first
end


# See: http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc435.htm
def initial_trend(y, period)
sum = 0
Expand All @@ -102,7 +103,6 @@ def initial_trend(y, period)
sum / (period * period)
end


# See: http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc435.htm
def seasonal_indicies(y, period, seasons)
seasonal_average = Array.new(seasons, 0.0)
Expand Down
3 changes: 2 additions & 1 deletion lib/holt_winters/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module HoltWinters
VERSION = "0.0.0"
VERSION = '0.0.0'.freeze
end