ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE LogNTransf;

  (*******************************************************************

    Module  LogNTransf     (Version 1.0)

      Copyright (c) 1996-2006 by Dimitrios Gyalistras and ETH Zurich.

    Purpose   Estimate parameters of Log-Normal distributions and
              perform transformations.

    Remarks   Missing data are recognized and returned as
              DMConversions.UndefREAL().


    Programming

      o Design
        Dimitrios Gyalistras      07/12/1996

      o Implementation
        Dimitrios Gyalistras      07/12/1996


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  19/12/1996  DG

  *******************************************************************)


  TYPE
    LnTrfType = ( noLnTrf, posSkewLnTrf, negSkewLnTrf );


  PROCEDURE GetLogNormalTransfParams( VAR data       : ARRAY OF REAL;
                                      nElems         : INTEGER;
                                      maxThetaFact   : REAL;
                                      VAR lnTrfType  : LnTrfType;
                                      VAR lnTrfMu    : REAL;
                                      VAR lnTrfSig   : REAL;
                                      VAR lnTrfTheta : REAL;
                                      VAR errTxt     : ARRAY OF CHAR ): BOOLEAN;

  (*
    Estimates parameters of transformation

             ln(  X - lnTrfTheta ),  if lnTrfType = posSkewLnTrf (X positively skewed)
    Xnew =   X,                      if lnTrfType = noLnTrf      (X weakly skewed)
             ln( -X - lnTrfTheta ),  if lnTrfType = negSkewLnTrf (X negatively skewed)

    where lnTrfMu, lnTrfSig are the mean and standard deviation of Xnew.

    The parameter lnTrfTheta is chosen sucht that it maximizes the
    likelihood that the transformed data stem from a Log-Normal
    distribution with parameters lnTrfMu/Sig/Theta.
    To this purpose lnTrfTheta is varied from (min-0.05*sig) to
    (min-maxThetaFact*sig) where min is the absolute minimum and
    sig the standard deviation of the input data.
  *)



  PROCEDURE LogNormalProbDensity( mu, sig, theta: REAL; x: REAL ):REAL;

  PROCEDURE LogNormalLnLikelihood( VAR data  : ARRAY OF REAL;
                                   nElems    : INTEGER;
                                   mu, sig   : REAL;
                                   theta     : REAL ):REAL;




  PROCEDURE LogNormalTransfPossible  ( forValue   : REAL;
                                       lnTrfType  : LnTrfType;
                                       lnTrfTheta : REAL ): BOOLEAN;

  PROCEDURE DoLogNormalTransf        ( lnTrfType  : LnTrfType;
                                       lnTrfTheta : REAL;
                                       VAR value  : REAL );

  PROCEDURE DoLogNormalTransfForArr  ( lnTrfType  : LnTrfType;
                                       lnTrfTheta : REAL;
                                       nElems     : INTEGER;
                                       VAR data   : ARRAY OF REAL );



  PROCEDURE UndoLogNormalTransf      ( lnTrfType  : LnTrfType;
                                       lnTrfTheta : REAL;
                                       VAR value  : REAL );

  PROCEDURE UndoLogNormalTransfForArr( lnTrfType  : LnTrfType;
                                       lnTrfTheta : REAL;
                                       nElems     : INTEGER;
                                       VAR data   : ARRAY OF REAL );




END LogNTransf.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]