Serving the Quantitative Finance Community

 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

qfcl/random

January 26th, 2015, 6:18 pm

QuoteI think all C++11 engines are thread safe, and thus so is that one.http://stackoverflow.com/questions/8813 ... eneratorsI don't see that. These seems to be no agreement???QuoteThe documentation makes no mention of thread safety, so I would assume they are not thread safe. I am not convinced. There seem to be no definitive statement saying it is or is not thread safe.
Last edited by Cuchulainn on January 25th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

qfcl/random

January 28th, 2015, 7:40 am

QuoteYou want a single random engine accessed by multiple threadsIdeally, yesQuoteYour worried about each thread with its own local random engine objects somehow having static shared memory that isn't thread safe?Yes, I am worried that C++11 Random is not really thread-safe.QuoteThink or random engines as containers: you can't have multiple threads inserting into a global std::vector without locking, but there is no problem in having a local std::vector in each thread. Like some thread-local storage?I was thinking of creating *several* rngs and initializing each one with std::seed_seq. But Normally NP (population) >> number of threads.Here's the example I have in my head (evolution algorithm, DE). Consider NP vectors each of size D. We index the vectors by i = 1,..., NP. So, we mutate each vector in sone way but essentially we need to generate three random indexes Unif[1,D] r1,r2, r3 that are not the same as each other and none of them equal to i (we need a loop to generate them until true). All other data is shared read only, so the only non-deterministic behavior lies in the generation of these random indices.// Since DE is all about randomness, is the odd race condition a disaster in this case?
Last edited by Cuchulainn on January 27th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

qfcl/random

March 20th, 2015, 6:47 pm

A recent talk on the aforementioned PCG:QuoteStanford Seminar - Melissa O'Neill of Harvey Mudd College"PCG: A Family of Better Random Number Generators" - Melissa O'Neill of Harvey Mudd CollegeColloquium on Computer Systems Seminar Series (EE380) presents the current research in design, implementation, analysis, and use of computer systems. Topics range from integrated circuits to operating systems and programming languages. It is free and open to the public, with new lectures each week.
Last edited by Polter on March 19th, 2015, 11:00 pm, edited 1 time in total.
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

qfcl/random

April 3rd, 2015, 9:09 am

Interesting discussion here:
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

qfcl/random

April 3rd, 2015, 1:02 pm

QuoteOriginally posted by: PolterInteresting discussion here: a bit like Peyton Place. I mean, when can it all stabilise?
Last edited by Cuchulainn on April 2nd, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

qfcl/random

May 7th, 2015, 8:45 am

QuoteOriginally posted by: CuchulainnQuoteThis links is for generating variates from the non-central chi^2 distribution hereAs well as this approach why not have a lite C version without all that Boost overhead? Just use a free function. Then it can be integrated into other libraries, and not just Boost-based. Now there is only one choice which is Boost which is not yet shipping.A more flexible solution would be less dependent on Boost. This is the library-independent part and is the meat (can the if-else be removed? avoid branching):bumpIs the code the last version?
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

qfcl/random

May 9th, 2015, 8:28 am

QuoteOriginally posted by: outrunQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: CuchulainnQuoteThis links is for generating variates from the non-central chi^2 distribution hereAs well as this approach why not have a lite C version without all that Boost overhead? Just use a free function. Then it can be integrated into other libraries, and not just Boost-based. Now there is only one choice which is Boost which is not yet shipping.A more flexible solution would be less dependent on Boost. This is the library-independent part and is the meat (can the if-else be removed? avoid branching):bumpIs the code the last version?yes, so far no need to change it.Still not included in boost, the maintainer is too busy and looks like he has different priorities now. I initially offered to help the lib maintainer to maintain and he was fine, but on second thought I don't have the skill, time, and interest beyond the things I want to add, so that's not a good idea really.In that case maybe it is an idea to _also_ have a Boost-free version (a template free function<URNG>) using doubles that implements those 6 lines of the Glasserman algorithm.
Last edited by Cuchulainn on May 8th, 2015, 10:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 20254
Joined: July 16th, 2004, 7:38 am
Location: 20, 000

qfcl/random

May 9th, 2015, 8:49 am

A follow-on remark is that Boost is not needed as C++11 supports normal, chi^2 and Poisson distributions.
Last edited by Cuchulainn on May 8th, 2015, 10:00 pm, edited 1 time in total.