#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, float xMin, float xMax, int nBin) // // Createur. //-- : Histo(xMin, xMax, nBin) { (*this)(0) = f(BinLowEdge(0)); for(int i=1; i= 1) return bins-1; // recherche du premier bin plus grand que z int iBin = 0; for (; iBin= 1) return max; // cas z <= tab[0] if (z <= (*this)(0)) { double t = min + binWidth/(*this)(0) * z; return t; } // recherche du premier bin plus grand que z int iBin = 0; for (; iBin max) t = max; return(t); } //////////////////////////////////////////////////////////////////////////// //++ // Class FunRan2D // Lib Outils++ // include perandom.h // // Tirage aleatoire sur un histogramme 2D. //-- //++ FunRan2D::FunRan2D(double *tab, int nBinX, int nBinY) // // Createur. //-- { // Tirage en X, somme sur les Y. double* tabX = new double[nBinX]; for (int i=0; i=0; i--) delete ranY[i]; delete[] ranY; delete ranX; } //++ void FunRan2D::BinRandom(int& x, int& 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(double& x, double& y) // // Tirage avec retour abscisse et ordonnee // du bin interpole. //-- { x = ranX->Random(); int i = int(ceil(x)); // FAILNIL(ranY[i]); Ne compile pas $CHECK$ Reza 22/04/99 y = ranY[i]->Random(); }