TradingView
RicardoSantos
2021年4月4日晚上9點27分

Function - Kernel Density Estimation (KDE) 

Bitcoin / U.S. dollarBitstamp

描述

"In statistics, kernel density estimation (KDE) is a non-parametric way to estimate the probability density function of a random variable."
from wikipedia.com

KDE function with optional kernel:
  • Uniform
  • Triangle
  • Epanechnikov
  • Quartic
  • Triweight
  • Gaussian
  • Cosinus


Republishing due to change of function.
deprecated script: tradingview.com/script/vWOxbhhj-KDE-Gaussian/

發布通知

added quartic and triweight kernels.

發布通知

  • added placeholder for kernels(logistic, sigmoid, silverman)
  • added kernel calculations for kernel(uniform, triangular, cosine)

發布通知

added calculations for kernels(logistic, sigmoid and silverman(Not working atm)

發布通知

removed silverman kernel, added highest value index line/label, nearest to 0 index as a dotted gray line.

發布通知

added extra stats/visuals to drawing function.
評論
kakola
That bandwidth is phire. 🔥
*phi*re
Yelian
Is it just me or does the script provide the same output regardless of the chart symbol?
Yelian
Can someone please provide some tips on how one may use this awesome script?
kakola
Can be updated to use pinescript's new "switch" function.
RicardoSantos
@kakola, this is now deprecated, V5 library version can be found here:
tradingview.com/script/oTcbPUuo-MathStatisticsKernelDensityEstimation/
THE_REAL_BCT
Nice little script... With one point I don't quite see how it works. Supposedly arrays can store up to 100K items. For whatever reason, I can't get more than 7 or 8 floats pushed into a float array or Pine blows up. So... That's not a whole lot of obs to infer a pdf

As a matter of fact I see you have 7 obs preloaded.

How do you load up obs beyond 7 ?

I have an idea for how to circumvent that limitations (using int array - altho I think they blow up at 50 or so) but want to see if you have something better? or maybe it's just a user/noob error and none of you guys see this problem?
RicardoSantos
@hypercrush1, yes the high complexity of the script limits its utility alot, unfortunely..
THE_REAL_BCT
@RicardoSantos, gotit. thanks. Love the code you produce!

BTW I just tried a script that does nothing else than push 'close' into a float array... then do 2 things (sequentially)
1/ ping array.size and display it, and it returns 1300+ or so - scrip executes fine
2/ get item before last pushed on the array/stack - Pine pukes. Error message "array size = 1" (so it looks like pine lied in 1/ and all along!)

Is that a Pine bug? or feature?
THE_REAL_BCT
@THE_REAL_BCT, Ignore the last comment - user error ;)
KB0006
Thanks for sharing this, I've been trying to find an indicator that uses kernel method and this seems to be the only one! Though I don't quite understand what those numbers suggest. Can you explain it to a dummy like myself? lol
更多