Subject: CGAL users discussion list
List archive
- From: Francois Berenger <>
- To:
- Subject: Re: [cgal-discuss] CGAL::Random
- Date: Wed, 22 Jun 2011 16:22:19 +0900
If you seed a random number generator (RNG) with every time the same seed, you get every time the same sequence.
If you don't understand, just use the code provided by Doug.
The RNG is seeded only once by doing how he does.
On 06/22/2011 04:17 PM, sara Samadi wrote:
I havent test your idea yet, but i think it is not important for
compiler that initialization is in or out of for loop because the
compiler translate the statement (CGAL::Random random) only one time.
--- On *Wed, 6/22/11, Doug Epps
/<>/*
wrote:
From: Doug Epps
<>
Subject: Re: [cgal-discuss] CGAL::Random
To:
Date: Wednesday, June 22, 2011, 5:04 AM
I believe (though i can't compile it right now) what Sylvain meant
was to do:
CGAL::Random random;
for (int t = 1; t<4; t++)
{
double randi=random.get_double (0.0, 1);
std::cout << "randi" << randi << std::endl;
}
Note how the CGAL::Random is OUTSIDE the loop, and so is in scope
for all 3 iterations of the loop, rather than being created for each
one.
My intuition is that the creation of the CGAL::Random object seeds
the random-number generator.
So you're getting the same thing over and over.
On Jun 21, 2011, at 9:50 PM, sara Samadi wrote:
> for (int t=1; t<4; t++)
> > {
> > CGAL::Random random;
> > double randi=random.get_double (0.0, 1);
> > double mandi=random.get_double (0.0, 1);
> > std::cout<<"randi="<<randi<<std::endl;
> > std::cout<<"mandi="<<mandi<<std::endl;
> > }
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- [cgal-discuss] CGAL::Random, sara123, 06/21/2011
- Re: [cgal-discuss] CGAL::Random, Sylvain Pion, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, sara Samadi, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, Doug Epps, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, sara Samadi, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, Guillaume Damiand, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, Francois Berenger, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, Laurent Rineau (GeometryFactory), 06/22/2011
- [cgal-discuss] Re: CGAL::Random, sara123, 06/28/2011
- Re: [cgal-discuss] CGAL::Random, sara Samadi, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, Doug Epps, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, sara Samadi, 06/22/2011
- Re: [cgal-discuss] CGAL::Random, Sylvain Pion, 06/22/2011
Archive powered by MHonArc 2.6.16.