Fix core WST file
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / normal.f
1 c===========================================================================
2 c
3 c   This file is part of TISEAN
4
5 c   Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
6
7 c   TISEAN is free software; you can redistribute it and/or modify
8 c   it under the terms of the GNU General Public License as published by
9 c   the Free Software Foundation; either version 2 of the License, or
10 c   (at your option) any later version.
11 c
12 c   TISEAN is distributed in the hope that it will be useful,
13 c   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 c   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 c   GNU General Public License for more details.
16 c
17 c   You should have received a copy of the GNU General Public License
18 c   along with TISEAN; if not, write to the Free Software
19 c   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 c
21 c===========================================================================
22 c   utilities for normalisation of time series
23 c   author T. Schreiber (1998)
24 c===========================================================================
25       subroutine rms(nmax,x,sc,sd)
26 c  return mean sc and rms amplitude sd
27       dimension x(nmax)
28
29       sc=0.
30       do 10 n=1,nmax
31  10      sc=sc+x(n)
32       sc=sc/nmax
33       sd=0.
34       do 20 n=1,nmax
35  20      sd=sd+(x(n)-sc)**2
36       sd=sqrt(sd/nmax)
37       end
38
39       subroutine normal(nmax,x,sc,sd)
40 c  subtract mean, return mean sc and rms amplitude sd
41       dimension x(nmax)
42
43       call rms(nmax,x,sc,sd)
44       do 10 n=1,nmax
45  10      x(n)=x(n)-sc
46       end
47
48       subroutine normal1(nmax,x,sc,sd)
49 c  subtract mean, rescale to unit variance, 
50 c  return mean sc and rms amplitude sd
51       dimension x(nmax)
52
53       call rms(nmax,x,sc,sd)
54       if(sd.eq.0.) stop 
55      .   "normal1: zero variance, cannot normalise"
56       do 10 n=1,nmax
57  10      x(n)=(x(n)-sc)/sd
58       end
59
60       subroutine minmax(nmax,x,xmin,xmax)
61 c  obtain smallest and  largest value in x
62       dimension x(nmax)
63
64       xmin=x(1)
65       xmax=x(1)
66       do 10 n=2,nmax
67          xmin=min(x(n),xmin)
68  10      xmax=max(x(n),xmax)
69       end
70