~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to contrib/surfphot/libsrc/mean.for

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
C @(#)mean.for  19.1 (ES0-DMD) 02/25/03 13:30:46
 
2
C===========================================================================
 
3
C Copyright (C) 1995 European Southern Observatory (ESO)
 
4
C
 
5
C This program is free software; you can redistribute it and/or 
 
6
C modify it under the terms of the GNU General Public License as 
 
7
C published by the Free Software Foundation; either version 2 of 
 
8
C the License, or (at your option) any later version.
 
9
C
 
10
C This program is distributed in the hope that it will be useful,
 
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
C GNU General Public License for more details.
 
14
C
 
15
C You should have received a copy of the GNU General Public 
 
16
C License along with this program; if not, write to the Free 
 
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
C MA 02139, USA.
 
19
C
 
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
C       Internet e-mail: midas@eso.org
 
22
C       Postal address: European Southern Observatory
 
23
C                       Data Management Division 
 
24
C                       Karl-Schwarzschild-Strasse 2
 
25
C                       D 85748 Garching bei Muenchen 
 
26
C                       GERMANY
 
27
C===========================================================================
 
28
C
 
29
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
30
C.IDENTIFICATION
 
31
C  subroutine MEAN           version 2         810727
 
32
C  A. Kruszewski             ESO - Garching
 
33
C.PURPOSE
 
34
C  calculates mean value "AMEAN" and sigma "SIGMA" of random
 
35
C  variable basing on a sample presented in form of an array
 
36
C.INPUT/OUTPUT
 
37
C  input arguments
 
38
C  A           real*4 array        data array
 
39
C  N           integer*4           number of values in "A"
 
40
C  output arguments
 
41
C  AMEAN       real*4              mean of data in "A"
 
42
C  SIGMA       real*4              sigma of data in "A"
 
43
C-----------------------------------------------------------------------
 
44
      SUBROUTINE MEAN(A,N,AMEAN,SIGMA)
 
45
C
 
46
      IMPLICIT  NONE
 
47
      INTEGER   N
 
48
      REAL      A(N)
 
49
      REAL      AMEAN
 
50
      REAL      SIGMA
 
51
C
 
52
      INTEGER   K
 
53
      REAL      SUM
 
54
      REAL      SSUM
 
55
      REAL      X
 
56
C
 
57
C
 
58
      SUM=0.0
 
59
      SSUM=0.0
 
60
C
 
61
C *** Calculates mean and sigma.
 
62
C
 
63
      DO 10 K=1,N
 
64
         SUM=SUM+A(K)
 
65
         SSUM=SSUM+A(K)*A(K)
 
66
10    CONTINUE
 
67
      AMEAN=SUM/N
 
68
      SSUM=SSUM/N
 
69
      X=AMEAN
 
70
         SSUM=SSUM-X*X
 
71
C
 
72
C *** Checks if "SSUM" is positive.
 
73
C
 
74
      IF (SSUM.GT.0.00001) THEN
 
75
         SIGMA=SQRT(SSUM*(N/FLOAT(N-1)))
 
76
      ELSE
 
77
         SIGMA=0.0
 
78
      END IF
 
79
      RETURN
 
80
      END