Showing posts from May, 2017

Nonrecursive fractal

A Koch snowflake.
CC-BY-SA Wikimedia Commons While thinking about the Koch snowflake it occurred to me that a recursive algorithm to generate one side of the curve would be trivial, but a non-recursive algorithm is pretty simple as well, although it took a lot of thought on my part to get it to work. I don't claim to be an expert at algorithms but I'm pleased when I can figure something out. Here's what I came up with. Your browser does not support the HTML5 canvas tag.Fractal order: 0 (click the arrows) The idea is to start out with the smallest generator unit, calculating its size by scaling per the length of the parent segments, and accumulating the rotation angles. Then draw the generator unit at that scale and rotation. Repeat for the total number of smallest generator units, which would be the number of segments in the unit to the power of (fractal order − 1).Here's the code including the graphics scaling. // display initialization and scaling var c = document.…

Fake data, part 4: Perturbing volatility

And here is part 4, which I drafted years ago but never published on my blog until now. I didn't quite get done with this project the way I wanted, but it's been a long time and I've moved on. Now I want to see if there is any dependency between successive moves in a market, compared to a random walk. I first built a 21×21 table (corresponding to the integers -10 to +10 on each axis) where each cell contains a count of how many times a move of [row] standard deviations was followed by a move of [column] standard deviations. For example, if the cell at [-2,1] contains the value 87, that means during the entire history of the market, a return of -2 standard deviations was followed by a return of +1 standard deviations 87 times. I used 48 years of data, about 12,0000 values for the S&P 500 index.Then I performed a Monte Carlo test. I scrambled the order of log returns (not prices) several hundred times and constructed a similar table containing the average count of each t…

Popular posts from this blog

The water rocket: Thrust from water

Most probable array of D&D ability scores

The water rocket: Launch tube thrust