Posts

Showing posts from 2010

Random walk oscillator

Image
May 2017: This is from my other blog that's no longer online. The original comments are no longer available, but you are welcome to add more.Here's an experiment. Suppose I want to make a random walk that I can control, that doesn't wander aimlessly all over, but rather is attracted to zero. The attraction back to zero wouldn't act like a force that causes steps away from zero to become smaller in size; rather, steps toward zero are simply more probable further away from zero, regardless of the step size. I'll invent a random walk that does this. We generate random walk steps in a generalized way via some inverse cumulative distribution function (cdf), which could represent a gaussian, a black swan, binary ±1 steps, whatever. This inverse cdf, in turn, takes as an input a random probability p that's uniformly-distributed between 0 and 1. (If you want uniformly-distributed steps, the step size simply equals the input p, or a multiple of p.)We need to skew this u…

Fake data part 3: Bypassing the central limit theorem

Image
May 2017: This is from my other blog that's no longer online. The original comments are no longer available, but you are welcome to add more.Now that I have my black swan distribution, and I verified that it fits market returns remarkably well while being mathematically tractable, I want to use it to generate artificial market data. Generating a series of closing prices is easy. Select a starting price, take the logarithmSelect a mean μ and standard deviation σ of log returns ln(P0/P1) where P0 is the most recent price and P1 is the previous price.Generate a uniformly-distributed random probability p between 0 and 1. Plug it into the inverse black swan distribution (using a=1.6):
$$B^{-1}(p;\mu,s) = \mu - 2 s \, \sinh \left[\frac {\tanh^{-1}(1-2p)} {a} \right]$$Add the result to a running total.Go to step 3. Repeat as often as desired. Then simply calculate the antilog or exponential of the values in the running total to get prices.This works fine. But what if we want to generate …

Fake data, part 2: The black swan distribution

Image
May 2017: This is from my other blog that's no longer online. The original comments are no longer available, but you are welcome to add more.In the previous part when I wrote about the logistic distribution, I observed that it fit the S&P 500 daily returns pretty well out to 5 standard deviations (much better than the normal distribution) but broke down in the tails beyond.That has been part of a weeks-long quest to find a distribution that fits, with the criterion that it must be closed-form; that is, we shouldn't need numerical methods to solve for the cumulative distribution or its inverse. Why do this? Because I want to generate an endless stream of artificial market data for analysis. Not only do I want my artificial market to exhibit behavior that is statistically similar a real-world market, but I also want closed-form expressions for ease of programming into Excel or whatever I'll use for analysis. The normal distribution fails on both counts.A normal distribut…

Fake data, part 1: The forgotten logistic distribution

Image
May 2017: This is from my other blog that's no longer online. The original comments are no longer available, but you are welcome to add more.Problem: We need to generate an endless stream of artificial market data, such that it maintains the statistical properties and behaviors of a real market. Everybody is familiar with the normal (Gaussian) distribution. The classic bell curve that underlies many tools in statistics. A normal distribution has a couple of glaring flaws, however:It requires numerical methods to calculate cumulative probability (area under the bell curve) and inverse of probability (i.e. for a known value of cumulative probability, what's the corresponding value of x?)It doesn't model many real-world situations well. Real-world distributions often have more outliers ("fatter tails" in the bell curve) than the normal distribution would suggest.Fortunately, there's a simple alternative: The logistic distribution. Like the normal distribution, i…