c++ - how can I get smaller scale in RAND function -
this question has answer here:
- c++ random float number generation 14 answers
i use code create random number between 0 , 1.
randnumber = (double)((double)rand() / (double)rand_max);
this line of code regularly give me numbers 0.650434, 0.302340 , 0.906789 big numbers me. problem need smaller range number these numbers: 0.000200, 0.000100, 0.000400, 0.000600 , on. how can modify line of code result?
do know kind of probability distribution function you're looking for? if still want uniform can divide [0,1) result large number , apply shift it's centered around value want.
if want that's distributed can use inverse transform method. again you'll need center , modify standard deviation. there similar transformations other distributions well
Comments
Post a Comment