@railpath/finance-toolkit
Version:
Production-ready finance library for portfolio construction, risk analytics, quantitative metrics, and ML-based regime detection
26 lines (25 loc) • 814 B
TypeScript
/**
* Calculate Skewness (Third Moment) of a dataset
*
* Skewness measures the asymmetry of the distribution:
* - Positive skewness: Distribution is skewed to the right (long right tail)
* - Negative skewness: Distribution is skewed to the left (long left tail)
* - Zero skewness: Symmetric distribution
*
* Formula: Skewness = E[(X - μ)³] / σ³
* Where:
* - μ = mean
* - σ = standard deviation
* - E[(X - μ)³] = third central moment
*
* @param data Array of numbers to calculate skewness for
* @returns Skewness value
*
* @example
* ```typescript
* const returns = [0.01, 0.02, -0.01, 0.03, -0.02, -0.05, 0.01];
* const skewness = calculateSkewness(returns);
* console.log('Skewness:', skewness); // -0.234
* ```
*/
export declare function calculateSkewness(data: number[]): number;