15 votes

Monitoring Apply / @@@ over large lists

You can always transform an expression of the form Apply[f,list,level] to the (almost) equivalent Map[Apply[f],list,level]. You ...
user avatar
  • 23.2k
15 votes
Accepted

Association vs Pair - Creation performance, Selection performance

Simply use keys = Range[1000000]; vals = Range[1000000]^2; result = Pick[vals, PrimeQ[keys]]; to get the best of both worlds (zero construction cost and even ...
user avatar
10 votes
Accepted

How to speed up the calculation of recurrence formula?

With memoization: Also, keep in mind that Mathematica uses 1-indexing, so the modulus needs to be calculated with offset 1 (please check if I got it correct): ...
user avatar
  • 35.5k
10 votes
Accepted

Fast double sum involving Kronecker symbol

...
user avatar
9 votes

Working around Memory Leak from HermiteDecomposition

Thanks to Mathematica Support, I have a workaround for the issue. Running the following code avoids the leak entirely: ...
user avatar
8 votes
Accepted

Monitoring Apply / @@@ over large lists

Probably many ways to do this. For instance, imagine you got a list of large integers list = Table[{RandomInteger[{10^20, 10^21}]}, 10] for which you need to check ...
user avatar
7 votes
Accepted

Speed Up the Gelman-Rubin-History function

Update: In the meantime, OP and I independently found out that Eigenvalues is not the bottleneck here as the dimensions of the matrices ...
user avatar
6 votes

What secrets are hidden away in your init.m file and where do you place it? Please do share!

I am an init.m ascetic. And I doubt after 30+ years of using Mathematica I will change. Everyone else, who wishes to, may proclaim how it is indispensable to their workflow, and I will accept their ...
6 votes

Monitoring Apply / @@@ over large lists

Practically speaking, this is what I actually do: First, if I need a variable to be dynamically updated, I use a global foo. Global side effects are generally a ...
user avatar
  • 213k
5 votes

What secrets are hidden away in your init.m file and where do you place it? Please do share!

I tend to put a lot of little functions in my init.m file, functions that take arguments and use module variables. I found that I would now have Global symbols like ...
5 votes

Monitoring Apply / @@@ over large lists

You can do something like: Module[{i}, result = Monitor[ Table[ Pause[0.1]; f @@ i, {i, RandomReal[1, {20, 3}]} ], i ] ] The ...
user avatar
  • 17.8k
5 votes

Parallelize for loop in mathematica

It is tempting to simply parallelize your approach. One seemingly obvious way would be to replace For and Sum loops by ...
user avatar
5 votes
Accepted

Solving equation over TruncatedDistribution (FindRoot)

You could pre-calculate symbolic expressions for the mean and standard deviation of the truncated distribution: ...
user avatar
  • 58.2k
4 votes

Solving equation over TruncatedDistribution (FindRoot)

Saving the truncated distribution's properties would allow for this calculation to proceed much more quickly. However, asking Mathematica to directly calculate the standard deviation of the truncated ...
user avatar
  • 8,313
1 vote

What secrets are hidden away in your init.m file and where do you place it? Please do share!

The documentation for init.m is functional, if sparse. There are no Examples, and there is no ...
1 vote
Accepted

get positions satisfying multiple criteria

Granted that your example may not be actually representative of what you ultimately want, here's an attempt: ...
user avatar
  • 3,452
1 vote

Solving equation over TruncatedDistribution (FindRoot)

I'm assuming you want to estimate the parameters using the "method of moments" rather than using maximum likelihood. (If not, then you should consider maximum likelihood as it computes much ...
user avatar
  • 33.4k
1 vote

Solving equation over TruncatedDistribution (FindRoot)

A straightforward approach is as follows. Its advantage is that you find Mean and StandardDeviation only one time. ...
user avatar
  • 16.5k

Only top scored, non community-wiki answers of a minimum length are eligible