Error using boost normal random generator

closed account (zbREy60M)
Hello, I am getting the error: error C2440: 'initializing' : cannot convert from 'boost::variate_generator<Engine,Distribution>' to 'double'
1> with
1> [
1> Engine=boost::mt19937 &,
1> Distribution=boost::normal_distribution<>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

The lines of code that are important are the parts where I copied a boost random generator sequence i found, and then inside the for loop the part where it is "double period = var_nor" is where the error is.
I have absolutely no idea what this means. Please help.
Thank you so much!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int main()
{

seed();
int m ;
cout << "How many Gravitars?\n\n";
cin >> m;

boost::mt19937 rng( time(0) );

  boost::normal_distribution<> nd(5, .69);

  boost::variate_generator<boost::mt19937&, 
                           boost::normal_distribution<> > var_nor(rng, nd);
double R;
ofstream myfile ("agedata.txt"); 
//("positiondata.txt");
for (R = 0; R < m; ++R)
{	
	double radius = sqrt(unifRandb())*RAND_MAX;
	double angle = unifRandb();
	double zed = unifRand();
	double age = unifRandb();
	double period = var_nor; // normal distribution of periods with a mean of 5 and a standard deviation of .69 seconds  
Last edited on
var_nor()
Topic archived. No new replies allowed.