File contents Statistics Library Skill
120+ statistical calculations in a single library - TradingView Featured Scripts inspired
Overview
Comprehensive statistics library providing 120+ calculations for quantitative analysis, risk metrics, and strategy optimization. Based on TradingView's featured statistical libraries with K.I.T. enhancements.
Categories
1. Descriptive Statistics (20+)
Function
Description
mean()
Arithmetic mean
median()
Median value
mode()
Most frequent value
variance()
Population variance
stdev()
Standard deviation
skewness()
Distribution asymmetry
kurtosis()
Distribution tail heaviness
range()
Max - Min
iqr()
Interquartile range
percentile()
Nth percentile
zscore()
Standardized score
mad()
Mean absolute deviation
cv()
Coefficient of variation
sem()
Standard error of mean
gmean()
Geometric mean
hmean()
Harmonic mean
wmean()
Weighted mean
trimean()
Tukey trimean
winsorize()
Winsorized mean
entropy()
Shannon entropy
2. Risk Metrics (25+)
Function
Description
sharpe()
Sharpe ratio
sortino()
Sortino ratio (downside)
calmar()
Calmar ratio
treynor()
Treynor ratio
omega()
Omega ratio
sterling()
Sterling ratio
burke()
Burke ratio
ulcer()
Ulcer index
pain()
Pain index
var()
Value at Risk
cvar()
Conditional VaR (Expected Shortfall)
maxDrawdown()
Maximum drawdown
avgDrawdown()
Average drawdown
recoveryTime()
Time to recover from DD
kellyFraction()
Kelly criterion position sizing
profitFactor()
Gross profit / Gross loss
expectancy()
Expected value per trade
sqn()
System Quality Number
lakeRatio()
Lake ratio
gainPain()
Gain to pain ratio
tail()
Tail ratio
commonSense()
Common sense ratio
cpc()
CPC index
kRatio()
K-ratio
martin()
Martin ratio
3. Correlation & Regression (20+)
Function
Description
pearson()
Pearson correlation
spearman()
Spearman rank correlation
kendall()
Kendall tau correlation
beta()
Market beta
alpha()
Jensen's alpha
r2()
R-squared
adjR2()
Adjusted R-squared
covariance()
Covariance
autocorr()
Autocorrelation
crosscorr()
Cross-correlation
linearReg()
Linear regression
polyReg()
Polynomial regression
expReg()
Exponential regression
logReg()
Logarithmic regression
powerReg()
Power regression
residuals()
Regression residuals
durbin()
Durbin-Watson statistic
vif()
Variance inflation factor
partialCorr()
Partial correlation
semiCorr()
Semi-correlation
4. Time Series (25+)
Function
Description
sma()
Simple moving average
ema()
Exponential moving average
wma()
Weighted moving average
hma()
Hull moving average
vwma()
Volume-weighted MA
dema()
Double EMA
tema()
Triple EMA
alma()
Arnaud Legoux MA
kama()
Kaufman adaptive MA
mcgd()
McGinley dynamic
linreg()
Linear regression value
diff()
First difference
pctChange()
Percent change
logReturn()
Logarithmic returns
momentum()
Price momentum
roc()
Rate of change
atr()
Average true range
tr()
True range
highest()
Highest value
lowest()
Lowest value
stoch()
Stochastic oscillator
rsi()
Relative strength index
cci()
Commodity channel index
adx()
Average directional index
aroon()
Aroon indicator
5. Distribution & Probability (15+)
Function
Description
normalPdf()
Normal probability density
normalCdf()
Normal cumulative distribution
normalInv()
Inverse normal
tPdf()
Student's t PDF
tCdf()
Student's t CDF
chiSqPdf()
Chi-squared PDF
chiSqCdf()
Chi-squared CDF
fPdf()
F-distribution PDF
fCdf()
F-distribution CDF
binomPmf()
Binomial PMF
binomCdf()
Binomial CDF
poissonPmf()
Poisson PMF
poissonCdf()
Poisson CDF
expPdf()
Exponential PDF
expCdf()
Exponential CDF
6. Hypothesis Testing (15+)
Function
Description
tTest()
Student's t-test
zTest()
Z-test
chiSqTest()
Chi-squared test
fTest()
F-test
anova()
Analysis of variance
mannWhitney()
Mann-Whitney U test
wilcoxon()
Wilcoxon signed-rank
kruskal()
Kruskal-Wallis test
levene()
Levene's test
shapiro()
Shapiro-Wilk normality
jarqueBera()
Jarque-Bera normality
adf()
Augmented Dickey-Fuller
kpss()
KPSS stationarity
granger()
Granger causality
cointegration()
Cointegration test
Usage
import stats from '@kit/statistics-library';
// Calculate Sharpe ratio
const sharpe = stats.sharpe(returns, riskFreeRate);
// Get full risk report
const riskReport = stats.riskReport(equity, {
riskFreeRate: 0.02,
benchmark: 'SPY',
confidence: 0.95
});
// Correlation matrix
const corrMatrix = stats.correlationMatrix([btc, eth, sol, avax]);
// Regression analysis
const reg = stats.linearReg(x, y, {
includeStats: true,
forecast: 10
});
Commands
kit stats calc <function> <data> - Calculate statistic
kit stats risk <equity> - Full risk report
kit stats corr <symbols> - Correlation matrix
kit stats test <hypothesis> <data> - Run hypothesis test
kit stats export <format> - Export calculations
Performance
Vectorized: Operations use SIMD where available
Streaming: Handle infinite data streams
Cached: Memoized calculations
GPU: Optional GPU acceleration for large datasets
1 --- 2 name: statistics-library 3 description: Statistics Library Skill 4 --- 5 # Statistics Library Skill 6 7 > 120+ statistical calculations in a single library - TradingView Featured Scripts inspired 8 9 ## Overview 10 11 Comprehensive statistics library providing 120+ calculations for quantitative analysis, risk metrics, and strategy optimization. Based on TradingView's featured statistical libraries with K.I.T. enhancements. 12 13 ## Categories 14 15 ### 1. Descriptive Statistics (20+) 16 | Function | Description | 17 |----------|-------------| 18 | `mean()` | Arithmetic mean | 19 | `median()` | Median value | 20 | `mode()` | Most frequent value | 21 | `variance()` | Population variance | 22 | `stdev()` | Standard deviation | 23 | `skewness()` | Distribution asymmetry | 24 | `kurtosis()` | Distribution tail heaviness | 25 | `range()` | Max - Min | 26 | `iqr()` | Interquartile range | 27 | `percentile()` | Nth percentile | 28 | `zscore()` | Standardized score | 29 | `mad()` | Mean absolute deviation | 30 | `cv()` | Coefficient of variation | 31 | `sem()` | Standard error of mean | 32 | `gmean()` | Geometric mean | 33 | `hmean()` | Harmonic mean | 34 | `wmean()` | Weighted mean | 35 | `trimean()` | Tukey trimean | 36 | `winsorize()` | Winsorized mean | 37 | `entropy()` | Shannon entropy | 38 39 ### 2. Risk Metrics (25+) 40 | Function | Description | 41 |----------|-------------| 42 | `sharpe()` | Sharpe ratio | 43 | `sortino()` | Sortino ratio (downside) | 44 | `calmar()` | Calmar ratio | 45 | `treynor()` | Treynor ratio | 46 | `omega()` | Omega ratio | 47 | `sterling()` | Sterling ratio | 48 | `burke()` | Burke ratio | 49 | `ulcer()` | Ulcer index | 50 | `pain()` | Pain index | 51 | `var()` | Value at Risk | 52 | `cvar()` | Conditional VaR (Expected Shortfall) | 53 | `maxDrawdown()` | Maximum drawdown | 54 | `avgDrawdown()` | Average drawdown | 55 | `recoveryTime()` | Time to recover from DD | 56 | `kellyFraction()` | Kelly criterion position sizing | 57 | `profitFactor()` | Gross profit / Gross loss | 58 | `expectancy()` | Expected value per trade | 59 | `sqn()` | System Quality Number | 60 | `lakeRatio()` | Lake ratio | 61 | `gainPain()` | Gain to pain ratio | 62 | `tail()` | Tail ratio | 63 | `commonSense()` | Common sense ratio | 64 | `cpc()` | CPC index | 65 | `kRatio()` | K-ratio | 66 | `martin()` | Martin ratio | 67 68 ### 3. Correlation & Regression (20+) 69 | Function | Description | 70 |----------|-------------| 71 | `pearson()` | Pearson correlation | 72 | `spearman()` | Spearman rank correlation | 73 | `kendall()` | Kendall tau correlation | 74 | `beta()` | Market beta | 75 | `alpha()` | Jensen's alpha | 76 | `r2()` | R-squared | 77 | `adjR2()` | Adjusted R-squared | 78 | `covariance()` | Covariance | 79 | `autocorr()` | Autocorrelation | 80 | `crosscorr()` | Cross-correlation | 81 | `linearReg()` | Linear regression | 82 | `polyReg()` | Polynomial regression | 83 | `expReg()` | Exponential regression | 84 | `logReg()` | Logarithmic regression | 85 | `powerReg()` | Power regression | 86 | `residuals()` | Regression residuals | 87 | `durbin()` | Durbin-Watson statistic | 88 | `vif()` | Variance inflation factor | 89 | `partialCorr()` | Partial correlation | 90 | `semiCorr()` | Semi-correlation | 91 92 ### 4. Time Series (25+) 93 | Function | Description | 94 |----------|-------------| 95 | `sma()` | Simple moving average | 96 | `ema()` | Exponential moving average | 97 | `wma()` | Weighted moving average | 98 | `hma()` | Hull moving average | 99 | `vwma()` | Volume-weighted MA | 100 | `dema()` | Double EMA | 101 | `tema()` | Triple EMA | 102 | `alma()` | Arnaud Legoux MA | 103 | `kama()` | Kaufman adaptive MA | 104 | `mcgd()` | McGinley dynamic | 105 | `linreg()` | Linear regression value | 106 | `diff()` | First difference | 107 | `pctChange()` | Percent change | 108 | `logReturn()` | Logarithmic returns | 109 | `momentum()` | Price momentum | 110 | `roc()` | Rate of change | 111 | `atr()` | Average true range | 112 | `tr()` | True range | 113 | `highest()` | Highest value | 114 | `lowest()` | Lowest value | 115 | `stoch()` | Stochastic oscillator | 116 | `rsi()` | Relative strength index | 117 | `cci()` | Commodity channel index | 118 | `adx()` | Average directional index | 119 | `aroon()` | Aroon indicator | 120 121 ### 5. Distribution & Probability (15+) 122 | Function | Description | 123 |----------|-------------| 124 | `normalPdf()` | Normal probability density | 125 | `normalCdf()` | Normal cumulative distribution | 126 | `normalInv()` | Inverse normal | 127 | `tPdf()` | Student's t PDF | 128 | `tCdf()` | Student's t CDF | 129 | `chiSqPdf()` | Chi-squared PDF | 130 | `chiSqCdf()` | Chi-squared CDF | 131 | `fPdf()` | F-distribution PDF | 132 | `fCdf()` | F-distribution CDF | 133 | `binomPmf()` | Binomial PMF | 134 | `binomCdf()` | Binomial CDF | 135 | `poissonPmf()` | Poisson PMF | 136 | `poissonCdf()` | Poisson CDF | 137 | `expPdf()` | Exponential PDF | 138 | `expCdf()` | Exponential CDF | 139 140 ### 6. Hypothesis Testing (15+) 141 | Function | Description | 142 |----------|-------------| 143 | `tTest()` | Student's t-test | 144 | `zTest()` | Z-test | 145 | `chiSqTest()` | Chi-squared test | 146 | `fTest()` | F-test | 147 | `anova()` | Analysis of variance | 148 | `mannWhitney()` | Mann-Whitney U test | 149 | `wilcoxon()` | Wilcoxon signed-rank | 150 | `kruskal()` | Kruskal-Wallis test | 151 | `levene()` | Levene's test | 152 | `shapiro()` | Shapiro-Wilk normality | 153 | `jarqueBera()` | Jarque-Bera normality | 154 | `adf()` | Augmented Dickey-Fuller | 155 | `kpss()` | KPSS stationarity | 156 | `granger()` | Granger causality | 157 | `cointegration()` | Cointegration test | 158 159 ## Usage 160 161 ```typescript 162 import stats from '@kit/statistics-library'; 163 164 // Calculate Sharpe ratio 165 const sharpe = stats.sharpe(returns, riskFreeRate); 166 167 // Get full risk report 168 const riskReport = stats.riskReport(equity, { 169 riskFreeRate: 0.02, 170 benchmark: 'SPY', 171 confidence: 0.95 172 }); 173 174 // Correlation matrix 175 const corrMatrix = stats.correlationMatrix([btc, eth, sol, avax]); 176 177 // Regression analysis 178 const reg = stats.linearReg(x, y, { 179 includeStats: true, 180 forecast: 10 181 }); 182 ``` 183 184 ## Commands 185 186 - `kit stats calc <function> <data>` - Calculate statistic 187 - `kit stats risk <equity>` - Full risk report 188 - `kit stats corr <symbols>` - Correlation matrix 189 - `kit stats test <hypothesis> <data>` - Run hypothesis test 190 - `kit stats export <format>` - Export calculations 191 192 ## Performance 193 194 - **Vectorized:** Operations use SIMD where available 195 - **Streaming:** Handle infinite data streams 196 - **Cached:** Memoized calculations 197 - **GPU:** Optional GPU acceleration for large datasets
Signal-Execution-Labs/forex-trading-ai-agent/tree/main/skills/statistics-library commit 91cb9ee9a3
Frequently asked questions How do I install the Statistics Library skill? Run npx skillmds@latest add signal-execution-labs/statistics-library in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Statistics Library skill do? Statistics Library Skill It is listed under Coding & Dev Tools on SkillMD.
Is Statistics Library safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Statistics Library? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Statistics Library free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Statistics Library? Signal-Execution-Labs (@signal-execution-labs) published this skill. Their other Agent Skills are listed on their SkillMD profile.