# Tag Info

5

I'll provide an starting point for 2D case with single particle. Collisions with other particles are likely to be hard to model (or at least require adding an massive amount of WhenEvent rules if implemented this way), since NDSolve and WhenEvent tend to miss discrete events. Also, 3D case would be considerably more complicated to build; likely to take more ...

3

This is pretty tricky due to the very heavy tail of the distribution. You can certainly get big speed ups as suggested by bill s by pre-computing some quantiles. However, there will always be a good chunk of the tail left to compute. I'm going to try to address the latter and borrow from Bill's solution for pre-computation. s[n_] := Log[n]*n^(-1.5); A ...

4

The following is (I believe) a better implementation for at least two reasons. First, it doesn't use the old Splines package, but Interpolation[..., Method -> "Spline"] instead. Second, if uses an algorithmic arc length parametrization to get the equispaced points instead of relying on the mesh generated by ParametricPlot which is nice for displaying but ...

5

If you are willing to precompute some things, it can be pretty quick. Here we precalculate 100000 terms of the $a_n$ sequence. Then calculate the CDF (cumulative distribution function) by using Accumulate. To find the closest term to the u, use a NearestFunction. capA = -Zeta'[3/2] // N; aAll = (Log[#]/#^1.5 & /@ Range[100000])/capA; accAll = ...

8

As I said in the comments, under the null hypothesis (in this case that the data was drawn from a particular distribution family) the p-value should follow a uniform distribution on (0,1). Let me illustrate with a simple z-test. ztest[data_, mu0_, sigma_] := Block[{z, p, d}, z = (Mean[data] - mu0)/(sigma/Sqrt[Length[data]]); d = NormalDistribution[]; ...

0

Delta functions are equivalent to a system of equations. They have several solutions. I am not quite sure, but it seems that it is this that is the reason for Mma doubts. sl = Solve[{-k1 - k2 + ka + kb == 0, e1^2 - k1^2 - m1^2 == 0, e2^2 - k2^2 - m2^2 == 0, -e1 - e2 + ea + eb == 0} , {k1, k2, e1, e2}]; You could help Mma as follows ...

5

Apparently in version 9 listability of the CDF for TransformedDistribution, at least in this particular case, was broken. As of version 10 this is no longer the case. However, there does appear to be a bug here. Named tests like PearsonChiSquareTest actually call DistributionFitTest under the hood so I will use the former to help point to the problem. The ...

6

I think this is the most compact I can get without defining my own function: InverseCDF[NormalDistribution[mu, sigma], prob]

4

The fastest way is probably a compiled sieve of Erostaneses. PrimesUpTo = Compile[{{n, _Integer}}, Block[{S = Range[2, n]}, Do[ If[S[[i]] != 0, Do[ S[[k]] = 0, {k, 2i+1, n-1, i+1} ] ], {i, Sqrt[n]} ]; Select[S, Positive] ], CompilationTarget -> "C", RuntimeOptions -> "Speed" ]; ...

2

Collecting timings for a range of starting values for the p parameter shows that the timing is critically dependent on this value. The peak happens to be close to the fitted value of p, 0.215. I assume that the gradient in the neigborhood is so low that the algorithm needs many iterations to converge. The multidimensionality of the situation won't help ...

0

@belisarius is right to point out that the frequency strongly depends on the programming style. The answer reported above are mostly applied for .m file (package) file, where there are many comments (* *), many strings "", such as in this code. (* Mathematica Package *) (* Created by the Wolfram Workbench 11-Jan-2010 *) (* TODO Way to pass down ...

1

As a rule, before going into Detail, it is a good idea to get first an overview over the situation, preferrably graphical. You could proceed like this. The problem can be formulated as follows: find the zeroes in x of the function $$f = p^x \binom{n}{x} (1-p)^{n-x}-q^x \binom{m}{a-x} (1-q)^{m-(a-x)}$$ In Mathematica define f as f[n_, p_, m_, q_, a_, x_] ...

3

I post here my own solution. I post here all the code I have written to generate low discrepancy sequences. The algorithms presented here are not necessarily optimized. Feel free to send me any corrections or improvements. Do not hesitate to post here also useful code to generate other low discrepancy sequence. Generation of a low discrepancy sequence ...

Top 50 recent answers are included