Tag Info

New answers tagged

0

RandomVariate[NormalDistribution[0,1]] If you want 10 such numbers: RandomVariate[NormalDistribution[0, 1], 10] Answering the question below: RandomVariate[TruncatedDistribution[{0, 1}, NormalDistribution[0, 1]], 12]


2

With N replaced by n and exact numbers, the function in the Question can be written as f[n_] = Sum[Binomial[n/2 - 1, a]*Binomial[n/2 - 1, a - 1]*(7/20)*(3/10)^(n - a - 1), {a, 2, n, 2}] Although Mathematica can perform the Sum, the result in terms of HypergeometricPFQ is not particularly enlightening. Instead, plot f[n]. ListLogPlot[Table[f[n], {n, ...


3

It is a bug in the caching feature. Some distributions don't have p-value corrections since those based on the empirical CDF must be derived individually. The result is correct but the p-value is inflated due to lack of correction. When the test or any underlying one is ran again it returns the cached result with no message.


5

summing random numbers between -0.5 and 0.5. the number of numbers to be summed is very large, like a 1000000 for example. The sum of $n$ identical Uniform random variables is known as a generalised Irwin-Hall distribution, implemented in Mathematica as the UniformSumDistribution [ see kguler's answer]. The latter takes an $n$-part piecewise ...


8

The built-in function UniformSumDistribution may be useful: usd[n_] := UniformSumDistribution[n, {-.5, .5}]; Plot[Evaluate[PDF[usd@#, x] & /@ Range[20]], {x, -2, 2}, PlotStyle -> (ColorData[{"Rainbow", {1, 20}}] /@ Range[20]), Exclusions -> None, PlotRange -> All, ImageSize -> 500, PlotLegends -> ("usd (" <> ToString[#] ...


11

Expanding on David's answer, this will be vastly faster on larger lists: With[{nf = Nearest[#]},EuclideanDistance[Last@nf[#, 2], #] & /@ #] &@myList For even faster results (e.g., on a list of 100K reals, this is ~250X faster than mine above, don't know how much faster than David's, I'd imagine many orders of magnitude): newF= ...


5

myList = RandomReal[{0, 10}, 1000]; nearestDistanceList = EuclideanDistance[Nearest[Complement[myList, {#}], #], #] & /@ myList; Histogram[nearestDistanceList]


1

The Variance Problem Find $Var(Z)$, where: $$Z = \begin{cases}W + X_1 & \text{if } W \leq c \\ W + X_2 & \text{if } W > c \end{cases}$$ where $\quad W \sim N(\mu_0, \sigma_0^2), \quad X_1 \sim N(\mu_1, \sigma_1^2), \quad X_2 \sim N(\mu_2, \sigma_2^2)$ are independent, and $c$ is a constant. Solution Let $f(w, x_1,x_2)$ denote the joint pdf ...


5

You can use BinormalDistribution instead of two univariate normal distributions: TransformedDistribution[Sqrt[x1^2 + x2^2], {x1, x2} ~Distributed~ BinormalDistribution[{0, 0}, {σ, σ}, 0]] (* RayleighDistribution[σ] *) TransformedDistribution[Sqrt[x1^2 + x2^2], {x1, x2} ~Distributed~ BinormalDistribution[{m, m}, {σ, σ}, 0]] (* RiceDistribution[Sqrt[2] m, ...


9

You can get the desired result in two steps: d1 = TransformedDistribution[x1^2 + x2^2, {Distributed[x1, NormalDistribution[0, σ]], Distributed[x2, NormalDistribution[0, σ]]}] (* ExponentialDistribution[1/(2 σ^2)] *) d2 = TransformedDistribution[Sqrt[z], Distributed[z, d1]] (* RayleighDistribution[σ] *) PDF[d2,r] $\begin{cases} \frac{r ...


3

dt = RandomVariate[BinomialDistribution[20, 0.6], 100]; dist = EmpiricalDistribution[dt]; range = Range[Min@#, 1 + Max@#] &@dist["Domain"]; pairs = Select[MapIndexed[Function[{x, pos}, Join @@ {{x}, Select[range[[First[pos] + 1 ;;]], PDF[dist, #] <= PDF[dist, x] && CDF[dist, x] + 1 - CDF[dist, #] >= .05 &, 1]}], ...


1

Fixed in 10.1 (windows) code S = {{2, 0.5}, {0.5, 1}}; Covariance[BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]]; Covariance[MultinormalDistribution[{0, 0}, S]]; Mean[BinormalDistribution[{0, 0}, {Sqrt[2], 1}, 0.5/Sqrt[2]]]; Mean[MultinormalDistribution[{0, 0}, S]]; NExpectation[x*y, {x, y} \[Distributed] BinormalDistribution[{0, 0}, ...



Top 50 recent answers are included