Changeset 3097 in Sophya for trunk/SophyaLib/NTools
- Timestamp:
- Oct 16, 2006, 7:17:55 PM (19 years ago)
- Location:
- trunk/SophyaLib/NTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/perandom.cc
r3075 r3097 239 239 Les variables aleatoires r,t sont independantes: 240 240 g(r,t) = g(r) g(t) 241 */ 241 - Attention: 242 La variable complexe "c=x+iy" ainsi definie verifie: 243 <|c|^2> = <c c*> = <x^2+y^2> = <r^2> = 2 sig^2 244 Si 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 9 9 #include "machdefs.h" 10 10 #include <stdlib.h> 11 #include <math.h> 11 12 #include "histos.h" 12 13 #include "srandgen.h" … … 42 43 }; 43 44 44 //! Returns a random gaussian complex numberwith variance sig^245 //! Returns a random complex number such that real and imaginary parts are gaussians with variance sig^2 45 46 inline complex< r_8 > ComplexGaussRan(double sig=1.) 46 47 {return complex< r_8 >(GauRnd(0.,sig),GauRnd(0.,sig));} 48 49 //! Returns the module of a random complex number generated by ComplexGaussRan 50 inline double ModComplexGaussRan(double sig=1.) 51 {double r=-log(1.-drand01()); return sig*sqrt(2.*r);} 47 52 48 53 } // namespace SOPHYA
Note:
See TracChangeset
for help on using the changeset viewer.