Software for Analysis of Multifractal Time Series 1.0.0

File: <base>/mf_moments_lt.awk (2,279 bytes)
# file: mf_moments_lt.awk                Y. Ashkenazy  8 Feb 2004
#                                        Last Revised: I. Henry 13 Oct 2004
#---------------------------------------------------------------------------
# mf_moments_lt.awk: calculate the tau(q) spectrum and the multifractal 
# spectrum, D(h), given the partition functions.
# Copyright (C) Yossi Ashkenazy
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#---------------------------------------------------------------------------
#
#
# Usage:
#
#  $ awk -f mf_moments_lt.awk -v a=1 -v b=3 file_name.zq > file_name.tq
#
# where: 
#  - a is the minimum log10 scale (1 in the above example)
#  - b is the maximum log10 scale (3 in the above example is 3)
#  - file_name.zq is the input filename that contains the partition function
#  - the output, file_name.tq, is the tau(q) spectrum and the D(h) spectrum.
#

BEGIN{
  s0=0.0;
  s1=s2=0.0;
  dq=0.2;
}
{
  if (NR==1)
    {
# read the data 
      q_min=$2;
      for (i=1;i<NF;i++)
        {
	  t0[i]=0.0;
	  t1[i]=0.0;;
	}
    }
  else
    {
# Fits the partition function is the desire range 
      if (($1>=a)&&($1<=b))
        {
          x=$1;
	  s0++;
	  s1+=x;
	  s2+=x*x;
	  for (i=2;i<=NF;i++)
	    {
	      t0[i-1]+=($i);
	      t1[i-1]+=x*($i);
	    }
        }
    }
}
END{
  for (i=1;i<NF;i++)
    {
# print tau(q) spectrum.
      q[i]=q_min+(i-1)*dq;
      tau[i]=(t1[i]*s0-s1*t0[i])/(s0*s2-s1*s1);
      print q[i],tau[i];
    }
  print "& &";
# print the D(h) spectrum 
  for (i=2;i<(NF-1);i++)
    print (tau[i+1]-tau[i-1])/(q[i+1]-q[i-1]),
	(tau[i+1]-tau[i-1])/(q[i+1]-q[i-1])*q[i]-tau[i];
}