ARIMA (Autoregressive Integrated Moving Average) is a time series forecasting method that combines autoregression, differencing, and moving average techniques to model time series data. ARIMA models are commonly used in fields such as finance, economics, and engineering to make predictions about future values based on historical data.
This function creates a debounced version of a function that delays invoking the original function until after a specified amount of time has elapsed since the last invocation of the debounced function.
const debouncedFunc = methodDebounce(func, wait, immediate, context);
func
(required): The function to debounce.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
format_uk_phone_number - A function to format UK phone numbers | |
This function takes in a phone number string and formats it according to UK phone number conventions. | |
@param {string} phone_number - The phone number to be formatted. | |
@returns {string} The formatted UK phone number string, or "Invalid UK phone number" if the input is invalid. | |
**/ | |
function format_uk_phone_number(phone_number) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DecisionTreeNode { | |
constructor(featureIndex, threshold, leftNode, rightNode, prediction) { | |
this.featureIndex = featureIndex; | |
this.threshold = threshold; | |
this.leftNode = leftNode; | |
this.rightNode = rightNode; | |
this.prediction = prediction; | |
} | |
isLeaf() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function holtWinters(alpha, beta, gamma, period, data) { | |
let seasonals = {}; | |
let r = []; | |
let initialSeasonals = []; | |
let detrended = []; | |
let forecast = []; | |
let dataPoints = data.length; | |
let avgSmooth = []; | |
let trendSmooth = []; | |
let seasonalSmooth = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inversePermutation(permutation) { | |
const n = permutation.length; | |
const result = Array(n); | |
for (let i = 0; i < n; i++) { | |
result[permutation[i] - 1] = i + 1; | |
} | |
return result; | |
} | |
// const permutation = [3, 1, 4, 5, 2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sattolosAlgorithm(array) { | |
const len = array.length; | |
for (let i = len - 1; i > 0; i--) { | |
const j = Math.floor(Math.random() * i); | |
[array[i], array[j]] = [array[j], array[i]]; | |
} | |
return array; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function knuthShuffle(arr) { | |
let currentIndex = arr.length; | |
let temporaryValue, randomIndex; | |
while (0 !== currentIndex) { | |
randomIndex = Math.floor(Math.random() * currentIndex); | |
currentIndex--; | |
temporaryValue = arr[currentIndex]; | |
arr[currentIndex] = arr[randomIndex]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return the natural dimensions of an image. | |
* @string img - The image to get the dimensions of. | |
* @return {object} - The natural width of the image. | |
* @return {null} - If the image has no natural dimensions. | |
*/ | |
function getNaturalDimensions({ naturalWidth, naturalHeight }) { | |
// get the image format from the src attribute. | |
let width = naturalWidth; |
NewerOlder