c++ - triangular distribution for creating four momentum vector -
c++ - triangular distribution for creating four momentum vector -
in problem create base of operations class represent 4 vector (a concept in physics involving 4 dimensional vector) create derived class represent 4 momentum of particle inherits base of operations class. have been supplied little piece of code utilize generate 'random' x y , z component of momentum magnitude. code follows
#include <cstdlib> double triangular(double momentum){ double x, y; do{ x = momentum*rand()/rand_max; y = x/momentum; } while (1.0*rand()/rand_max > y); homecoming x; }
it said in problem code supposed generate magnitude, , randomly split x, y , z components. code returns single value , cannot see how doing says in problem. help me understand code doing , how used create 3 components of momentum magnitude. give thanks kindly.
c++ random triangular
Comments
Post a Comment