Linked Questions

602 votes
19 answers

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
181 votes
8 answers

List of compilable functions

Is there somewhere a list on the functions that Compile can compile, or the cases in which a particular function can be compiled that I haven't found? I'd be glad ...
Rojo's user avatar
  • 42.6k
183 votes
6 answers

How to compile effectively?

What are the best practices of compiling functions? I understand that this is a vague question, but let me list some aspects that might trigger useful answers. Some of these have already been answered ...
István Zachar's user avatar
25 votes
4 answers

Can Mathematica's random number generation be improved?

Performance on Random Number generation is intolerable. Whenever you need many deviates from the same distribution but with different parameters it takes forever. Here is a thread on Poisson deviates ...
JEP's user avatar
  • 1,336
18 votes
4 answers

Speeding up Gaussian sampling

Edit Greg Hurst answers show how to independently get 3x speed-up using single-threaded MKL implementation and 4x speed-up by using native implementation with multi-threading, can they be combined? ...
Yaroslav Bulatov's user avatar
22 votes
2 answers

Efficient Generation of Random Variates from a Copula Distribution

I have a 7-asset portfolio for which I want to simulate daily log-deltas using a Student T copula. The marginal distributions are all either Stable or TsallisQGaussian. Using NMaximize, I have ...
user6062's user avatar
  • 321
18 votes
1 answer

Speed up adding Poisson noise to an image

I'm simulating some images corrupted with Poisson noise, but I'm encountering a few problems with performance. According to the documentation on ImageEffect, one ...
dr.blochwave's user avatar
  • 8,798
14 votes
2 answers

What's the most "functional" way to do Cholesky decomposition?

I can do Cholesky in a procedural style, such as: ...
Editortoise-Composerpent's user avatar
12 votes
1 answer

What function generates random numbers in a compiled function?

I am writing a simulation for 2D random walk. I wrote several version of code, and found that the speed is like this (fastest to slowest): C++, Mathematica compiled procedural code, Mathematica ...
vapor's user avatar
  • 7,921
3 votes
1 answer

Sampling a Dirichlet Distribution efficiently

I'm sampling a DirichletDistribution like so: ...
Lokdal's user avatar
  • 405
8 votes
1 answer

Speeding Up RandomVariate

Consider the following code where we first take 1000 independent samples from a Poisson distribution, and then take 1000 independent samples from 1000 different Poisson distributions: ...
Ian Hincks's user avatar
  • 1,859
1 vote
1 answer

Is there any way to compile and export LearnedDistribution?

I use the LearnDistribution function to learn the distribution of some data. Then, I want to export some code to sample from that learned distribution. I tried to use Compile as follows ...
sepehr78's user avatar
1 vote
1 answer

How to compile the following code (sampling from a distribution)?

Consider the following code: ...
John Taylor's user avatar
  • 5,827
2 votes
0 answers

How to use Compile? Bivariate Gibbs Sampler

I am trying to use compile to speed up my Gibbs sampler. I know I can use Reap and Sow to speed up tremendously. I have a more complicated Bayesian posterior that I want to speed up with compile so I ...
ADDonut's user avatar
  • 139
3 votes
1 answer

Compiling a function that uses MapThread

I'm looking for tips on quickly applying the following update to $B$ pairs of $(w_i,x_i)$ $$\text{step}(w_i,x_i)=w_i-a x_i \langle w_i, x_i \rangle$$ Below is a readable but very slow version ...
Yaroslav Bulatov's user avatar

15 30 50 per page