Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
106 views

Optimizing a While Loop for High-Precision Computation in Mathematica

Edit: Clarifying the Core Issue i=x; While[Abs[p1 - p2] >= p1 tol, p2 = p1; p1 += s *= i (mkn + i)/((k1 - i) (n1 - i)); i--; ]; The core of my ...
Dotman's user avatar
  • 580
2 votes
1 answer
123 views

Fastest way to approximate CDF in Mathematica

I need a very fast way to approximate the CDF of HypergeometricDistribution in Mathematica. I need to evaluate it for very large ...
Dotman's user avatar
  • 580
2 votes
0 answers
137 views

Insights on using the HypergeometricDistribution functions in Mathematica

I'm trying to calculate the upper confidence interval for the hypergeometric distribution in mathematica and I came up with this very simple code. ...
Dotman's user avatar
  • 580
4 votes
1 answer
121 views

Best way to implement the "plus-distribution" for very long expressions?

I'm at my wits end here. Is there an efficient way to implement the following distribution into MMA: $$\int_0^y dx \frac{f(x)-f(y)}{y-x}$$ where $f/1-x$ can be analytically integrated. The difficulty ...
Confuse-ray30's user avatar
0 votes
0 answers
31 views

SmoothKernelDistribution only uses 1 core

I have a huge amount of datasets, each containing many elements, and trying to convert it to PDF using SmoothKernelDistribution. I see that applying it to 1 dataset ...
John Taylor's user avatar
  • 5,963
4 votes
1 answer
235 views

How to quickly sample points from the given PDF data?

Consider some data (distr.dat). It is a tabulated PDF: x, y, z, PDF[x,y,z], where x is some parameter (and the integral of ...
John Taylor's user avatar
  • 5,963
1 vote
2 answers
133 views

What is the best (fastest and accurate) way to obtain PDF from the given dataset?

Consider some list of two coordinates, points, generated by some arbitrary function function1 (which is a pdf up to a ...
John Taylor's user avatar
  • 5,963
0 votes
0 answers
38 views

Slow SmoothKernelDistribution of WeightedData

Consider some data in the form data = {{x,y,weight(x,y)},...}; I make wd = WeightedData[data[[All,{1,2}]],data[[All,3]]]; I ...
John Taylor's user avatar
  • 5,963
4 votes
1 answer
74 views

Speeding up RandomVariate with custom probability distribution

I have the defined a custom distribution, which is a Gaussian where the exponent can be any real n greater than 0 (set to actually be >0.5 in use), i.e. ...
Xyive's user avatar
  • 115
0 votes
1 answer
94 views

How to generate random value under the given distribution fast?

Consider a distribution distr[EN_, Enu_, mN_] = Exp[-(Sqrt[EN^2 + mN^2]/Enu)]*Sqrt[(Sqrt[Enu^2-mN^2]/2)^2 - EN^2] Sqrt[ EN^4 - (Enu/4)^4] where mN is a free ...
John Taylor's user avatar
  • 5,963
5 votes
4 answers
274 views

Solving equation over TruncatedDistribution (FindRoot)

I'm trying to solve the following equation : ...
Jocelyn Minini's user avatar
4 votes
1 answer
179 views

Determining Mean Path Length

I'm interested in working out the average path length in a square. Assume at a single point within the square, photons are released in every direction. I'm interested in determining the average path ...
Tomi's user avatar
  • 4,768
1 vote
0 answers
41 views

Speed up exact distribution of the sum of the top $k$ statistics on a bounded discrete uniform distribution?

I came across a nice answer by Sasha (I believe a Wolfram engineer) on mathematics stack exchange regarding the distribution of the sum of the top $k$ order statistics. (This was an answer to an RPG ...
ciao's user avatar
  • 26k
-1 votes
1 answer
138 views

How to improve `FindDistribution`? [closed]

Table[{n, FindDistribution[RandomSample[ Join @@ Table[ConstantArray[k, Binomial[n, k]], {k, 0, n}] ], TargetFunctions -> "Discrete"]}, {n, 15}] // TableForm ...
მამუკა ჯიბლაძე's user avatar
1 vote
0 answers
53 views

Can LearnDistribution Train and Generate Images Without Defaulting To 256x256?

In spite of anything I try it seems the ConformImages[] function nested in the LearnDistribution[] function resizes images to 256x256. If I convert an image into its "Data" representation before ...
agibilium's user avatar
3 votes
3 answers
133 views

Efficient function for life duration probability?

Sent to me by a colleague asking me for assistance (the function as is breaks): ...
ciao's user avatar
  • 26k
0 votes
2 answers
105 views

How to speed up this calculation regarding the normal distribution?

This calculation takes a very long time! Why? How can I improve it? Thanks! ...
GambitSquared's user avatar
3 votes
1 answer
106 views

How can Distribution fitting be sped up?

The first line generates 1050 data points to fit. The second line fits this data to the same distribution. This takes about 100ms on my computer. Doing this with ...
Michael B. Heaney's user avatar
7 votes
2 answers
2k views

Can this code be changed to run faster?

I've worked for several days trying to get this code to run faster. The imported data is 15MB. ...
Michael B. Heaney's user avatar
1 vote
0 answers
60 views

Why is this parallel notebook not maxing out the available memory and processors?

I've searched many questions about parallel processing here, and they are either specialized or over my head. I run the following parallel notebook on an 8 core EC2 instance. The average memory usage ...
Michael B. Heaney's user avatar
4 votes
0 answers
76 views

Why is ProbabilityDistribution 100x slower than ExtremeValueDistribution?

The two distributions are the same, except the ProbabilityDistribution cuts out below x=0. The wolfram documentation on ProbabilityDistribution says nothing about speed. A search of this site gave no ...
Michael B. Heaney's user avatar
3 votes
2 answers
90 views

Fix a vertex at a known location in SpatialGraphDistribution

I can very quickly generate random geometric graphs with ...
apg's user avatar
  • 2,223
3 votes
1 answer
390 views

Sampling a Dirichlet Distribution efficiently

I'm sampling a DirichletDistribution like so: ...
Lokdal's user avatar
  • 405
3 votes
2 answers
222 views

Fast way to evaluate the PDF of a multivariable distribution

I'm trying to evaluate the PDF of a truncated multi-normal distribution. My distribution has 8 dimensions and each value must be ≥ 0. ...
BPinto's user avatar
  • 1,032
4 votes
1 answer
258 views

Performance of a bootstrap - time of computation not linear with number of iterations

I'm doing a bootstrap based on this thread with the following code (file.txt here): ...
corey979's user avatar
  • 24.3k
2 votes
0 answers
115 views

Optimization of custom probability distibutions?

Consider the two tests: Timing[Do[RandomVariate[NormalDistribution[0.5, 0.3]], {200}]] {0.001188, Null} ...
JeffDror's user avatar
  • 1,890
7 votes
1 answer
583 views

How to get probabilities for multinomial & hypergeometric distribution ranges more quickly?

I often need to calculate the probability of a result from a multinomial distribution falling within some range, e.g., the maximum of the categories having an upper bound, or a lower bound for the ...
ciao's user avatar
  • 26k
2 votes
2 answers
392 views

Performance in calculating maximum-likelihood- based estimates

My probability density function is a complicated one for which numerical estimation is necessary. Here my pdf: ...
Remi.b's user avatar
  • 1,155
1 vote
0 answers
155 views

How to properly (efficiently) define a mixture distribution and optimize the likelihood?

To start with: ...
Chen Stats Yu's user avatar
18 votes
1 answer
2k views

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
4 votes
1 answer
182 views

Example from Mathematica documentation (ExtremeValueDistribution) seems to be evaluating "forever"

Bug introduced in 9.0.1 or earlier and persisting through 11.0.1 or later I am referring to this example at the reference page for the extreme value distribution: http://reference.wolfram.com/...
vonjd's user avatar
  • 1,605
22 votes
2 answers
2k views

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