New answers tagged performance-tuning
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 ...
Community wiki
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 ...
Community wiki
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 ...
Community wiki
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 ...
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):
...
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 ...
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 ...
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 ...
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 ...
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:
...
10
votes
Accepted
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:
...
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 ...
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.
...
5
votes
Accepted
Solving equation over TruncatedDistribution (FindRoot)
You could pre-calculate symbolic expressions for the mean and standard deviation of the truncated distribution:
...
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 ...
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 ...
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 ...
Top 50 recent answers are included
Related Tags
performance-tuning × 2638list-manipulation × 428
matrix × 214
numerical-integration × 147
parallelization × 147
compile × 146
plotting × 139
equation-solving × 115
mathematical-optimization × 113
differential-equations × 110
programming × 106
linear-algebra × 99
functions × 86
numerics × 85
memory × 82
graphs-and-networks × 80
code-review × 74
image-processing × 66
sparse-arrays × 66
function-construction × 62
calculus-and-analysis × 58
probability-or-statistics × 54
graphics × 53
table × 53
import × 45