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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -