#!/bin/sh # # A license is hereby granted to reproduce this software source code # and to create executable versions from this source code for # personal, non-commercial use. The copyright notice included with # the software must be maintained in all copies produced. # # THIS PROGRAM IS PROVIDED "AS IS". THE AUTHOR PROVIDES NO WARRANTIES # WHATSOEVER, EXPRESSED OR IMPLIED, INCLUDING WARRANTIES OF # MERCHANTABILITY, TITLE, OR FITNESS FOR ANY PARTICULAR PURPOSE. THE # AUTHOR DOES NOT WARRANT THAT USE OF THIS PROGRAM DOES NOT INFRINGE # THE INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY IN ANY COUNTRY. # # So there. # # Copyright (c) 1994-2005, John Conover, All Rights Reserved. # # Find the root, (reciprocal of the Hausdorff fractal dimension,) of # the DJIA time series, djia1900-2004, to three decimal places, by # iterating the tsrunmagnitude(1) program. (Note: the iteration # technique is "fragile," and convergence is not guaranteed.) # # The program uses the last calculated value of the root of the # fractional Brownian equivalent of the time series for the DJIA, to # calculate a new root value. In pseudo code: # # using the tsmath program, take the log of the time series of the # DJIA to produce the fractional Brownian equivalent of the DJIA # time series; use the tslsq program to LSQ the linear trend # # while the error is more than 0.000 # # use the tsrunmagnitude program to make a time series of the # root of the fractional Brownian equivalent of the DJIA time # series # # take the log, using the tsmath program, of both axis of the # fractional Brownian equivalent of the DJIA time series, # i.e., make a log-log plot; the slope of the plot is the root # of the fractional Brownian equivalent of the DJIA time # series # # we need 843 days of data, (ln (843) = 6.7, grep'ing 0-5 will # give 5.999 ... which is close,) and use the tslsq program to # LSQ the slope; strip out the root value, and calculate the # error from the last iteration # # On the DJIA time series, from January 2, 1900, to October 12, 2004, # inclusive, (it takes about 22 minutes on a half GHz. Pentium class # machine): # # LSQ Approximation = -4.588093 + 0.537910t, Error = 0.03791 # LSQ Approximation = -4.645150 + 0.541671t, Error = 0.003761 # LSQ Approximation = -4.650391 + 0.542009t, Error = 0.000338 # Final LSQ Approximation -4.650391 + 0.542009t # # The deviation is e^(-4.650391) = 0.00955786407, and the root is # 0.542009, or the formula for the deviation of the DJIA, t many days # into the future will be 0.00955786407 * t^0.542009. # # John Conover, john@email.johncon.com # tsmath -l djia1900-2004 | tslsq -o > djia1900-2004.brownian # ROOT="0.5" # while [ "1" != "2" ] do tsrunmagnitude -r "${ROOT}" djia1900-2004.brownian > djia1900-2004.brownian.root cut -f1 djia1900-2004.brownian.root | tsmath -l > 1.tmp cut -f2 djia1900-2004.brownian.root | tsmath -l > 2.tmp SLOPE=`paste 1.tmp 2.tmp | egrep '^[0-5]\.' | tslsq -p` paste 1.tmp 2.tmp > djia1900-2004.brownian.root.log-log rm -f 1.tmp 2.tmp LASTROOT="${ROOT}" ROOT=`echo "${SLOPE}" | sed -e 's/^.* + //' -e 's/t$//'` DIFF=`calc "${ROOT}" - "${LASTROOT}" | sed 's/^[^0-9]//'` echo "LSQ Approximation = ${SLOPE}, Error = ${DIFF}" # if echo "${DIFF}" | egrep '0\.000' > /dev/null then echo "Final LSQ Approximation ${SLOPE}" break; fi # done