Alec  Nikolaus

Alec Nikolaus

1596589200

Holt-Winters Exponential Smoothing

A super-fast forecasting tool for time series data

Holt-Winters Exponential Smoothing is used for forecasting time series data that exhibits both a trend and a seasonal variation. The Holt-Winters technique is made up of the following four forecasting techniques stacked one over the other:

Image for post

**Weighted Averages: **A weighted average is simply an average of n numbers where each number is given a certain weight and the denominator is the sum of those n weights. The weights are often assigned as per some weighing function. Common weighing functions are logarithmic, linear, quadratic, cubic and exponential. Averaging as a time series forecasting technique has the property of smoothing out the variation in the historical values while calculating the forecast. By choosing a suitable weighing function, the forecaster determines which historical values should be given emphasis for calculating future values of the time series.

**Exponential Smoothing: **The Exponential Smoothing (ES) technique forecasts the next value using a weighted average of all previous values where the weights decay exponentially from the most recent to the oldest historical value. When you use ES, you are making the crucial assumption that recent values of the time series are much more important to you than older values. The ES technique has two big shortcomings: It cannot be used when your data exhibits a trend and/or seasonal variations.

**Holt Exponential Smoothing: **The Holt ES technique fixes one of the two shortcomings of the simple ES technique. Holt ES can be used to forecast time series data that has a trend. But Holt ES fails in the presence of seasonal variations in the time series.

Holt-Winters Exponential Smoothing: The Holt-Winters ES modifies the Holt ES technique so that it can be used in the presence of both trend and seasonality.

To understand how Holt-Winters Exponential Smoothing works, one must understand the following four aspects of a time series:

Level

The concept of level is best understood with an example. The following time series shows the closing stock price of Merck & Co. on NYSE. The horizontal red lines indicate some of the levels in the time series in its up and down journey:

Image for post

Data source: Yahoo Finance

Trend

A time series whose level changes in some sort of a pattern is said to have a trend. A time series whose level changes randomly around some mean value can be said to exhibit a random trend. Apart from knowing that the trend is random, the concept of trend is not so useful when it’s random, compared to one where the trend can be modeled by some function.

Let’s zoom into one particular area of the above stock price chart to illustrate the concept of a positive trend:

Image for post

An illustration of a positive trend between two consecutive levels

Some of the commonly observed trends are linear, square, exponential, logarithmic, square root, inverse and 3rd degree or higher polynomials. These trends can be easily modeled using the corresponding mathematical function, namely, log(x), linear, x², exp(x) etc.

Highly non-linear trends require complex modeling techniques such as artificial neural networks to model them successfully.

A useful way to look at trend is as a rate or as the velocity of the time series at a given level.

This makes trend a vector that has a magnitude (rate of change) and a direction (increasing or decreasing).

Let’s kept this interpretation of trend as a rate or velocity at the back of our minds. We’ll use it when we deconstruct the forecasting equation of Holt-Winters Exponential Smoothing.

#python #time-series-analysis #time-series-forecasting #data-science

What is GEEK

Buddha Community

Holt-Winters Exponential Smoothing
Alec  Nikolaus

Alec Nikolaus

1596589200

Holt-Winters Exponential Smoothing

A super-fast forecasting tool for time series data

Holt-Winters Exponential Smoothing is used for forecasting time series data that exhibits both a trend and a seasonal variation. The Holt-Winters technique is made up of the following four forecasting techniques stacked one over the other:

Image for post

**Weighted Averages: **A weighted average is simply an average of n numbers where each number is given a certain weight and the denominator is the sum of those n weights. The weights are often assigned as per some weighing function. Common weighing functions are logarithmic, linear, quadratic, cubic and exponential. Averaging as a time series forecasting technique has the property of smoothing out the variation in the historical values while calculating the forecast. By choosing a suitable weighing function, the forecaster determines which historical values should be given emphasis for calculating future values of the time series.

**Exponential Smoothing: **The Exponential Smoothing (ES) technique forecasts the next value using a weighted average of all previous values where the weights decay exponentially from the most recent to the oldest historical value. When you use ES, you are making the crucial assumption that recent values of the time series are much more important to you than older values. The ES technique has two big shortcomings: It cannot be used when your data exhibits a trend and/or seasonal variations.

**Holt Exponential Smoothing: **The Holt ES technique fixes one of the two shortcomings of the simple ES technique. Holt ES can be used to forecast time series data that has a trend. But Holt ES fails in the presence of seasonal variations in the time series.

Holt-Winters Exponential Smoothing: The Holt-Winters ES modifies the Holt ES technique so that it can be used in the presence of both trend and seasonality.

To understand how Holt-Winters Exponential Smoothing works, one must understand the following four aspects of a time series:

Level

The concept of level is best understood with an example. The following time series shows the closing stock price of Merck & Co. on NYSE. The horizontal red lines indicate some of the levels in the time series in its up and down journey:

Image for post

Data source: Yahoo Finance

Trend

A time series whose level changes in some sort of a pattern is said to have a trend. A time series whose level changes randomly around some mean value can be said to exhibit a random trend. Apart from knowing that the trend is random, the concept of trend is not so useful when it’s random, compared to one where the trend can be modeled by some function.

Let’s zoom into one particular area of the above stock price chart to illustrate the concept of a positive trend:

Image for post

An illustration of a positive trend between two consecutive levels

Some of the commonly observed trends are linear, square, exponential, logarithmic, square root, inverse and 3rd degree or higher polynomials. These trends can be easily modeled using the corresponding mathematical function, namely, log(x), linear, x², exp(x) etc.

Highly non-linear trends require complex modeling techniques such as artificial neural networks to model them successfully.

A useful way to look at trend is as a rate or as the velocity of the time series at a given level.

This makes trend a vector that has a magnitude (rate of change) and a direction (increasing or decreasing).

Let’s kept this interpretation of trend as a rate or velocity at the back of our minds. We’ll use it when we deconstruct the forecasting equation of Holt-Winters Exponential Smoothing.

#python #time-series-analysis #time-series-forecasting #data-science

Utkarsh Khare

1563305330

How Holt- winter is different from Machine Learning? #Holt-Winter vs #ML?

What are similarities and differences between the two when dealing with time series?

#python

Retrying and Exponential Backoff With Promises

When you don’t have an interface for knowing when a remote resource is available, an option to consider is to use exponential backoff rather than to poll that resource until you get a response.

Image for post

Set Up

In this scenario, let’s mimic the behaviour of a browser and a server. Let’s say the server has an abysmal failure rate of 80%.

const randomlyFail = (resolve, reject) =>
  Math.random() < 0.8 ? reject() : resolve();

const apiCall = () =>
  new Promise((...args) => setTimeout(() => randomlyFail(...args), 1000));

The apiCall function mimics the behaviour of calling an endpoint on a server.

Retrying

When the apiCall is rejected, getResource is called again immediately.

const getResource = () => apiCall().catch(getResource);

With a Delay

If a server is already failing, it may not be wise to overwhelm it with requests. Adding a delay to the system can be a provisional solution to the problem. If possible, it would be better to investigate the cause of the server failing.

const delay = () => new Promise(resolve => setTimeout(resolve, 1000));

const getResource = () =>
  apiCall().catch(() => delay().then(() => getResource()));

#javascript #exponential-backoff #asynchronous-programming #retry #promises #programming

Hollie  Ratke

Hollie Ratke

1597190400

jQuery / Plugin / jQuery Smooth Scroll

jQuery Smooth Scroll

jQuery Smooth Scroll은 HTML 내에서 링크를 클릭하여 이동할 때, 부드럽게 이동하도록 만들어주는 플러그인입니다.

기본 사용법

  • 다음처럼 문서 내에서 이동하는 링크를 가진 HTML 문서를 만듭니다.
<!doctype html>
<html lang="ko">
	<head>
		<meta charset="utf-8">
		<title>jQuery</title>
		<style>
			body { font-family: Consolas, sans-serif; }
			a { color: blue; }
			p { margin-bottom: 800px; }
		</style>
	</head>
	<body>
		<ul>
			<li><a href="#ipsum">Ipsum</a></li>
			<li><a href="#dolor">Dolor</a></li>
		</ul>
		<h1>Lorem</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
		<h1 id="ipsum">Ipsum</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
		<h1 id="dolor">Dolor</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
	</body>
</html>

  • HTML 문서에 다음 코드를 추가합니다. 보통 위 또는 위에 넣습니다.
  • jquery.smooth-scroll.js의 경로는 적절히 수정하세요.
<script src="//code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="js/jquery.smooth-scroll.js"></script>
<script>
	$( document ).ready( function() {
		$( 'a' ).smoothScroll();
	} );
</script>
  • 이제 링크를 클릭하면 스르륵 그 위치로 이동합니다.

비디오 플레이어

00:00

00:08

특정 링크에만 적용시키는 방법

  • 특정 링크에만 적용시키고 싶다면 선택자를 이용하세요. 다음은 ul 태그 안에 있는 링크에 대해서만 Smooth Scroll을 적용하는 예제입니다.
<!doctype html>
<html lang="ko">
	<head>
		<meta charset="utf-8">
		<title>jQuery</title>
		<style>
			body { font-family: Consolas, sans-serif; }
			a { color: blue; }
			p { margin-bottom: 800px; }
		</style>
		<script src="//code.jquery.com/jquery-3.5.1.min.js"></script>
		<script src="js/jquery.smooth-scroll.js"></script>
		<script>
			$( document ).ready( function() {
				$( 'ul a' ).smoothScroll();
			} );
		</script>
	</head>
	<body>
		<ul>
			<li><a href="#ipsum">Ipsum</a></li>
		</ul>
		<a href="#dolor">Dolor</a>
		<h1>Lorem</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
		<h1 id="ipsum">Ipsum</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
		<h1 id="dolor">Dolor</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
	</body>
</html>
  • Ipsum을 클릭하면 부드럽게 이동하지만, Dolor를 클릭하면 바로 이동합니다.

비디오 플레이어

00:00

00:07

옵션

jQuery Smooth Scroll에는 여러 가지 옵션이 있습니다. 이동 속도를 조절하거나, 이동 방식을 변경하거나, 이동 전 또는 이동 후에 어떤 작업을 수행할 수 있습니다.

다음은 이동 위치를 조정하는 예제입니다.

<!doctype html>
<html lang="ko">
	<head>
		<meta charset="utf-8">
		<title>jQuery</title>
		<style>
			body { font-family: Consolas, sans-serif; }
			a { color: blue; }
			p { margin-bottom: 800px; }
		</style>
		<script src="//code.jquery.com/jquery-3.5.1.min.js"></script>
		<script src="js/jquery.smooth-scroll.js"></script>
		<script>
			$( document ).ready( function() {
				$( 'ul a' ).smoothScroll( {
					offset: -100
				} );
			} );
		</script>
	</head>
	<body>
		<ul>
			<li><a href="#ipsum">Ipsum</a></li>
			<li><a href="#dolor">Dolor</a></li>
		</ul>
		<h1>Lorem</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
		<h1 id="ipsum">Ipsum</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
		<h1 id="dolor">Dolor</h1>
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non ipsum massa. Pellentesque vel dapibus elit. Fusce at rhoncus nisl, sit amet facilisis ante. Morbi vestibulum diam ac congue maximus. Nullam quis risus auctor, congue leo quis, pellentesque diam. Morbi scelerisque, odio quis egestas tincidunt, tellus nunc auctor mi, pellentesque sagittis erat felis quis dolor. Integer sit amet velit quis leo placerat imperdiet. Pellentesque tempus nulla nec porttitor rhoncus.</p>
	</body>
</html>

비디오 플레이어

#jquery #plugin #jquery smooth #codingfactory

Vue Developers

Vue Developers

1589677710

Smooth Scrollbar directive for Vue.js

What is smooth-scrollbar?

Smooth Scrollbar is a JavaScript Plugin that allows you customizing high perfermance scrollbars cross browsers. It is using translate3d to perform a momentum based scrolling (aka inertial scrolling) on modern browsers. With the flexible plugin system, we can easily redesign the scrollbar as we want. This is the scrollbar plugin that you’ve ever dreamed of!

Browser Compatibility

Browser Version
IE 10+
Chrome 22+
Firefox 16+
Safari 8+
Android Browser 4+
Chrome for Android 32+
iOS Safari 7+

Smooth Scrollbar Preview

How to use vue smooth scrollbar

npm i @morioh/v-smooth-scrollbar

or

yarn add @morioh/v-smooth-scrollbar

Register

import Vue from 'vue'
import ScrollBar from '@morioh/v-smooth-scrollbar'

// global register
Vue.use(ScrollBar);

or use via CDN

<script src="https://cdn.jsdelivr.net/npm/@morioh/v-smooth-scrollbar/dist/scrollbar.min.js" type="text/javascript"></script>

unpkg CDN

<script src="https://unpkg.com/@morioh/v-smooth-scrollbar/dist/scrollbar.min.js" type="text/javascript"></script>
<div v-scrollbar style="height: 500px">
  <img src="https://i.imgur.com/vIhs3zq.jpg" style="width:100%">
</div>

Common mistakes

Initialize a scrollbar without a limited width or height
Likes the native scrollbars, a scrollable area means the content insides it is larger than the container itself, for example, a 500x500 area with a content which size is 1000x1000:

              container
                 /
       +--------+
  #####################
  #    |        |     #
  #    |        |     #
  #    +--------+     # -- content
  #                   #
  #                   #
  #####################

Therefore, it’s necessary to set the width or height for the container element:

<div v-scrollbar style="max-height: 500px; max-height:500px"></div>

<div v-scrollbar style="height: 500px; height:500px"></div>

Horizontal Scrollbar

<div v-scrollbar style="width: 300px;">
  <div>
    <img style="width:500px" src="https://i.imgur.com/vIhs3zq.jpg">
  </div>

</div>

If the container element is natively scrollable before initializing the Scrollbar, it means you are on the correct way.

Smooth Scrollbar directive options

<div v-scrollbar="{}" style="height: 500px;"></div>
parameter type default description
damping number 0.1 Momentum reduction damping factor, a float value between (0, 1), the lower the value is, the more smooth the scrolling will be (also the more paint frames).
thumbMinSize number 20 Minimal size for scrollbar thumbs.
renderByPixels boolean true Render every frame in integer pixel values, set to true to improve scrolling performance.
alwaysShowTracks boolean false Keep scrollbar tracks always visible.
continuousScrolling boolean true Set to true to allow outer scrollbars continue scrolling when current scrollbar reaches edge.
wheelEventTarget EventTarget null Element to be used as a listener for mouse wheel scroll events. By default, the container element is used. This option will be useful for dealing with fixed elements.

Demo: https://lab.morioh.com/v-smooth-scrollbar/

Source Code: https://github.com/Morioh-Lab/v-smooth-scrollbar

Smooth Scrollbar: https://github.com/idiotWu/smooth-scrollbar


Recommended

Quill Rich Text Editor component for Vue.js

Markdown Editor component for Vue.js

Simple notify handler component for Vue.js

Lightbox Photo Grid and Slideshow component for Vue.JS

Video Embed Component for Vue.JS

#vue #scrollbar #smooth-scrollbar #vue.js