Found on JohnnyQ's OneNote per poster request @griftingthrulife
It should be noted that the author doubts its usefulness:
It should be noted that the author doubts its usefulness:
15:10 AlphaInvestor: I have the Laplace Distribtion coded ... no idea how to turn it into something useful
Ruby:
# Laplace Matrix
# AlphaInvestor
# 6.12.2019
# Laplace Probability Density Function
#
# Location is the mean
# Scale specifies the spread of the distribution (for Laplace dist
# scale = standard deviation / square root(2)). The ideal scale factor
# for a Laplace distribution is the standard deviation of the population
# divided by the square root of two.
#
# The calibrated scale factor I [paper author] used to match the event
# frequency in the 5 sigma or larger tails was the ideal scale factor
# times 1.19 of the close price with respect to the low to high range
# for the same period.
#
# Source:
#
# Predicting Stock Market Returns—Lose the Normal and Switch to Laplace
# February 21, 2019 by Vance Harwood
# Six Figure Investing
# Everyone agrees the normal distribution isn't a great statistical model
# for stock market returns, but no generally accepted alternative has
# emerged. A bottom-up
declare lower;
input length = 60;
input avgType = averagetype.SIMPLE;
input price = close;
input scaleMult = 1.19; # 1.19 suggested by paper author for S&P 500
script LaplacePDF {
input x = 0 ; # the close
input u = 1 ; # the mean
input b = 2 ; # the scale parameter
def a1 = exp(-(absvalue(x - u)/b));
def a2 = 1 / (2 * b);
def a3 = a2 * a1;
plot Lpdf = a3;
}
def location = MovingAverage(avgType, price, length);
def scale = stdev(price,length) / sqrt(2); # SPX 1.19, IWM 1.17, AAPL 1.12 (to fit 5 sigma move)
def myScale = scale * scalemult;
plot Laplace = LaplacePDF(price,location,myScale);
Laplace.setdefaultcolor(color.light_gray);
# End Study
Last edited: