Skip to main content
34 events
when toggle format what by license comment
Aug 23, 2018 at 21:37 answer added Henrik Schumacher timeline score: 5
Apr 13, 2017 at 12:56 history edited CommunityBot
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Oct 6, 2016 at 7:33 history edited dr.blochwave CC BY-SA 3.0
deleted 455 characters in body
Feb 24, 2015 at 3:36 history edited JEP CC BY-SA 3.0
deleted 2 characters in body
Feb 24, 2015 at 1:34 history edited JEP CC BY-SA 3.0
Added an explanation for the motivation of this question and a short discussion of the 3 answers.
Feb 20, 2015 at 23:45 comment added ciao @jep Then you use the same technique where the parameter RVs are defined by your inputs. Pretty basic stuff.
Feb 20, 2015 at 23:07 comment added dr.blochwave Ok, I understand now, thanks for clarifiying
Feb 20, 2015 at 22:56 comment added JEP My input parameters come from a simulation. They don't have a known parametric distribution.
Feb 20, 2015 at 22:31 comment added dr.blochwave @JEP why not? The example provided by rasher below gives the same histogram as MMA or C++, and is very quick to generate and draw from (especially for very large draws of $>10^{7}$)
Feb 20, 2015 at 22:23 comment added JEP If you are assuming a distribution for the input parameters on the parametric generation then you are not generating the random numbers that I need.
Feb 20, 2015 at 22:12 comment added ciao @blochwave: Added...
Feb 20, 2015 at 22:01 comment added dr.blochwave @rasher look forward to seeing it, especially if it beats the C++!
Feb 20, 2015 at 22:00 comment added ciao @blochwave: That 200ms was on a netbook, 6x faster than the R example on same - but it's basic MMA thinking: Use ParametricMixture to get dist, PDF (or CDF depending on dist type), use PDF to drive RandomChoice (or CDF for inversion). Will add binomial example to my answer when time permits.
Feb 20, 2015 at 21:56 history edited dr.blochwave CC BY-SA 3.0
improved the layout of the question, easier to read, formatted the C code block as C not MMA.
Feb 20, 2015 at 21:47 comment added dr.blochwave @rasher out of interest, what was your code for the parametric generation of 10^6 binomial variates? 200ms is close to the performance of the C++ code (150ms)
Feb 20, 2015 at 19:55 review Close votes
Feb 20, 2015 at 23:22
Feb 20, 2015 at 19:28 comment added ciao @AlbertRetey well said.
Feb 20, 2015 at 19:27 comment added ciao Seeing as intelligent use of Mathematica provided faster generation than the C and R examples below, I don't think it's WRI that needs to do any fixing. Perhaps the Experimental`AngerManagement package needs a spin...
Feb 20, 2015 at 17:10 comment added JEP Sorry about that. I wasn't trying to trick anyone into reading anything. The first line in my post is: "Performance on Random Number generation is intolerable." I'm not sure why you kept reading if you don't care about performance. WRI can fix it or not.
Feb 20, 2015 at 15:50 comment added Albert Retey If you feel hostility I think that might have to do with the fact that you chose to use a quite aggressive title, which also isn't in line with your actual question. You might realize that many readers would be seriously concerned about broken random number generators while they are neither surprised nor worried to hear that Mathematica is slow for this kind of task. They might (as I did) feel being tricked into reading your (lengthy) question in the first place...
Feb 20, 2015 at 6:25 vote accept JEP
Feb 19, 2015 at 5:09 history tweeted twitter.com/#!/StackMma/status/568276258372620289
Feb 18, 2015 at 22:32 answer added JEP timeline score: 7
Feb 18, 2015 at 15:23 history edited JEP CC BY-SA 3.0
deleted 32 characters in body
Feb 18, 2015 at 15:15 history edited JEP CC BY-SA 3.0
improved formatting
Feb 18, 2015 at 15:13 comment added wolfies Yes - but your question is messy. A good question simplifies the problem down to 1 or 2 lines (if possible), and it is certainly possible to do so here. By contrast, your question appears lazy, because it just dumps lines and lines of code from whatever you were doing, without honing it down to the heart of the matter. 2 lines: no more. Further, your title asks if it can be FIXED, which infers that it is broken. But your question is not about quality, nor do you compare the quality of pseudorandom drawings generated, nor does your post suggest anything is broken.
Feb 18, 2015 at 13:58 history edited JEP CC BY-SA 3.0
deleted 35 characters in body
Feb 18, 2015 at 13:04 comment added JEP f should not have been there. Other than that ints, reals, and mus were all used as arguments to the distributions. I am detecting hostility here which I do not understand. I don't understand the point of comments that don't address the question. My point is that if you can generate random variates all at once the performance is comparable to C so it is false that "of course compiled C is faster than Mathematica." There are many simulation problems in which random numbers with different parameters are needed as in the examples I provided.
Feb 18, 2015 at 12:53 comment added JEP I was not aware that symbolic calculations have anything to do with random number generation? ??
Feb 18, 2015 at 10:57 comment added wolfies I don't get the point either. If you want to do a comparison, get it down to 2 lines of code. Do you really need to define num, ints, reals, mus, f, mf, rvs, gf ... just to do a timing test? Talking of efficient, who has time to look through all that?
Feb 18, 2015 at 8:33 answer added dr.blochwave timeline score: 40
Feb 18, 2015 at 7:43 answer added ciao timeline score: 37
Feb 18, 2015 at 6:58 comment added ciao What's your point? Of course compiled C is faster than Mathematica. So call your C from it if that kind of speed is critical for this simplistic stuff. On the other hand, I'll wait patiently while you use your C code to evaluate complex probabilistic equations symbolically...
Feb 18, 2015 at 6:25 history asked JEP CC BY-SA 3.0