#include "machdefs.h" #include "pexceptions.h" #include "perandom.h" #include "pemath.h" #include //////////////////////////////////////////////////////////////////////////// //++ // Class FunRan // Lib Outils++ // include perandom.h // // Tirage aleatoire sur un histogramme 1D. //-- //++ FunRan::FunRan(FunRan::Func f, r_8 xMin, r_8 xMax, int_4 nBin) // // Createur. //-- : Histo(xMin, xMax, nBin) { (*this)(0) = f(BinLowEdge(0)); for(int_4 i=1; i= 1) return mBins-1; // recherche du premier bin plus grand que z int_4 iBin = 0; for (; iBin= 1) return mMax; // cas z <= tab[0] if (z <= (*this)(0)) { r_8 t = mMin + binWidth/(*this)(0) * z; return t; } // recherche du premier bin plus grand que z int_4 iBin = 0; for (; iBin mMax) t = mMax; return(t); } //////////////////////////////////////////////////////////////////////////// //++ // Class FunRan2D // Lib Outils++ // include perandom.h // // Tirage aleatoire sur un histogramme 2D. //-- //++ FunRan2D::FunRan2D(r_8 *tab, int_4 nBinX, int_4 nBinY) // // Createur. //-- { // Tirage en X, somme sur les Y. r_8* tabX = new r_8[nBinX]; for (int_4 i=0; i=0; i--) delete ranY[i]; delete[] ranY; delete ranX; } //++ void FunRan2D::BinRandom(int_4& x, int_4& y) // // Tirage avec retour du numeros de bin. //-- { x = ranX->BinRandom(); // FAILNIL(ranY[x]); Ne compile pas $CHECK$ Reza 22/04/99 y = ranY[x]->BinRandom(); } //++ void FunRan2D::Random(r_8& x, r_8& y) // // Tirage avec retour abscisse et ordonnee // du bin interpole. //-- { x = ranX->Random(); int_4 i = int_4(ceil(x)); // FAILNIL(ranY[i]); Ne compile pas $CHECK$ Reza 22/04/99 y = ranY[i]->Random(); }