Changeset 3097 in Sophya for trunk/SophyaLib/NTools


Ignore:
Timestamp:
Oct 16, 2006, 7:17:55 PM (19 years ago)
Author:
cmv
Message:

precisions sur ComplexGaussRan cmv 16/10/2006

Location:
trunk/SophyaLib/NTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/perandom.cc

    r3075 r3097  
    239239  Les variables aleatoires r,t sont independantes:
    240240    g(r,t) = g(r) g(t)
    241 */
     241- Attention:
     242La variable complexe "c=x+iy" ainsi definie verifie:
     243              <|c|^2> = <c c*> = <x^2+y^2> = <r^2> = 2 sig^2
     244Si on veut generer une variable complexe gaussienne telle que
     245     <c c*> = s^2 alors il faut sig = s/sqrt(2) comme argument
     246*/
  • trunk/SophyaLib/NTools/perandom.h

    r3075 r3097  
    99#include "machdefs.h"
    1010#include <stdlib.h>
     11#include <math.h>
    1112#include "histos.h"
    1213#include "srandgen.h"
     
    4243};
    4344
    44 //!  Returns a random gaussian complex number with variance sig^2
     45//! Returns a random complex number such that real and imaginary parts are gaussians with variance sig^2
    4546inline complex< r_8 > ComplexGaussRan(double sig=1.)
    4647  {return complex< r_8 >(GauRnd(0.,sig),GauRnd(0.,sig));}
     48
     49//! Returns the module of a random complex number generated by ComplexGaussRan
     50inline double ModComplexGaussRan(double sig=1.)
     51  {double r=-log(1.-drand01()); return sig*sqrt(2.*r);}
    4752
    4853} // namespace SOPHYA
Note: See TracChangeset for help on using the changeset viewer.