Tag Info

Hot answers tagged

12

UPDATE: quite interesting parallel discussion and solutions (see Emerson Willard answer) can be found HERE. Maybe this is not exactly what you are looking for, but at least this gives you a very close guess and it is easy to figure out the rest. dis = ProbabilityDistribution[ 1/(2*E^((-m + Log[5])^2/8)*Sqrt[2*Pi]), {m, -Infinity, Infinity}]; PDF[dis, ...


10

In this particular example the P-values can be found with the following: 2 (1 - CDF[StudentTDistribution[2], 0.268373]) 2 (1 - CDF[StudentTDistribution[2], 2.95892]) The "2" in StudentTDistribution[2] is the degrees of freedom calculated from the sample size (4) minus the number of parameters estimated (2). In this case the P-value is the probability of ...


9

If you don't care about the algorithm and only want to sample points with density according to image brightness, you could just use RandomChoice: using a test image that looks a little bit like a PDF: img = Image[ Rescale[Array[ Sin[#1^2]*Cos[#2 + Sin[#1/5]] + Exp[-(#1^2 + #2^2)/2] &, {512, 512}, {{-2., 4.}, {-3., 3.}}]]]; I can then ...


9

f[m_] = 1/(2*E^((-m + Log[5])^2/8)*Sqrt[2*Pi]); Integrate[f[m], {m, -Infinity, Infinity}] 1 dist = ProbabilityDistribution[f[m], {m, -Infinity, Infinity}]; Since the integral of f[m] is unity, f[m] does not have to be scaled to be a distribution. A candidate distribution will probably have two parameters and must be defined on the interval ...


8

You can't use non-numeric data for EmpiricalDistribution (at least up to V9, and I saw nothing when I had 10.x installed that said otherwise). Deal with it as character codes: gc = ToCharacterCode@ToLowerCase@gettys; p3 = Partition[gc, 3, 1]; d = EmpiricalDistribution@p3; Probability[{a, b, c} == ToCharacterCode@"the" \[Conditioned] {a, b} == ...


7

To me this looks like a bug. A possible workaround is to use ProbabilityDistribution together with the PDF of the VonMisesDistribution: SeedRandom[1] RandomVariate@ProbabilityDistribution[PDF[VonMisesDistribution[0, 0], x], {x, -∞, ∞}] $\ $ 1.99422 This bug is caused by the evaluation of Statistics`NormalDistributionsDump`compiledvonmisesrandom[0, 0, ...


6

The problem arises due to PiecewiseExpand operating inside TransformedDistribution, similarly to the following pw = PiecewiseExpand[f[Max[x, y], z]] (* Piecewise[{{f[x, z], x - y >= 0}}, f[y, z]] *) however this kind of transformation is not appropriate when f is TransformedDistribution pw /. {f -> TransformedDistribution, z -> {x ...


5

Increase WorkingPrecision: NSolve[PDF[BinomialDistribution[80, p], 0] == 0.95`200 && 0 < p < 1, p, Reals, WorkingPrecision -> 50] PDF[BinomialDistribution[80, p], 0] /. % (* {{p -> 0.00064096067673218860969986162632491931947341012861}} {0.9500000000000000000000000000000000000000000000000} *)


4

As noted in the comment by WRI staff, this is indeed a bug in the interplay between RandomVariate and the distribution at hand. The obvious workaround for now is to use UniformDistribution[{μ - Pi, μ + Pi}] for zero-concentration cases.


4

Here is one way of defining the linearity of your expectation value. Updated in response to comments To allow for powers as they arise in the definition of the variance, I just added rules that expand such powers when possible (it is only possible when there is a sum under the power, that's why I restrict the pattern expect[Power[expr_Plus, n_]] to ...


4

Here's a start for you. p is probability of choosing die 1, f1/f2 are number of faces (starting at 1) for die 1/2: p1 = 3/10 f1 = 6 f2 = 20 d = MixtureDistribution[{p1, 1 - p1}, {DiscreteUniformDistribution[{1, f1}], DiscreteUniformDistribution[{1, f2}]}]; d2 = TransformedDistribution[a + b, {a, b} \[Distributed] ...


4

While the unknown g might or might not be amenable to this approach, it's really fast on g == 1: Expectation[ 1, {x1, x2, x3, x4} \[Distributed] MultinormalDistribution[muvec, sigmat]] // RepeatedTiming (23000 times faster than NIntegrate.) Then there's also NExpectation to try, too. Ever since I came across Guess who it is's use of the ...


4

I get on Mathematica 10.2, Ubuntu 14.04 In[10]:= Map[{First[ Timing[Do[ RandomVariate[BinomialDistribution[10 #, 1/#]], {100}]]], First[Timing[ Do[RandomVariate[ BinomialDistribution[10 #, 1/(# + 1)]], {100}]]]} &, {1500, 3000, 5000, 10000}] Out[10]= {{0.023484, 2.37428}, {0.012502, 6.22335}, {0.013843, 12.4218}, ...


4

Please edit with your results: MMa 10.0.0.0, Windows 8.1 – Sektor {0.015625, 0.03125}, {0.`, 0.0625}, {0.`, 0.125}, {0.`, 0.`}} MMa 10.0.0.0 through MinGW & mintty, Windows 8.1 – Sektor {0., 0.03125}, {0., 0.0625}, {0., 0.125}, {0., 0.}} MMA 10.2, Ubuntu 12.04 - blochwave {0.03, 0.1, ...


3

You can actually do the integral in closed form: f[z_] = Integrate[Exp[-x^2/2] Exp[-y^2/2] DiracDelta[x y - z]/(4 Pi), z, {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, Assumptions -> z ∈ Reals] and then Plot Plot[f[z], {z, -2, 2}] To change the variances: f[z_] = Integrate[Exp[-x^2/(2 sigX^2)] Exp[-y^2/(2 sigY^2)] DiracDelta[x y ...


3

Because the integrand is highly localized at the origin; e.g., Log[10, npdf[{6, 0, 0, 0}]] // N (* -9.16177 *) limiting the range of integration reduces run time by a factor of three and moderately improves accuracy. muvec = ConstantArray[1/10, 4]; sigmat = IdentityMatrix[4]; npdf[x_] := PDF[MultinormalDistribution[muvec, sigmat], x]; ...


3

One obvious answer is to use the answer to your related earlier question with the straightforward modification of renaming the random variables: Clear[expect] expect[expr_Plus] := Map[expect, expr] expect[Times[x_, y__]] /; (FreeQ[x, x1 | x2 | x3 | x4]) := x expect[Times[y]] expect[Times[x_expect, y__]] := x expect[Times[y]] expect[expr_?(FreeQ[#, x1 ...


2

(Just an extension of belisarius' excellent answer which I have upvoted.) The physically meaningful approach to the determination of FWHM requires working with actual physical intensity values, not gamma-corrected and artificially deformed intensity values which one gets with the usual photographic cameras generating images in the sRGB colorspace. If it is ...


2

The bin-sizes (which is what you interval sizes) can be specified directly in Histogram: Histogram[RandomReal[-30, 40], {5}] Btw, it's funny when you say random numbers from RandomReal[-30,30] (where the size of the list is 40) and you just specified to get a list with 30 random numbers :-) Edit: Ahh, and now I see why you said it. When you want ...


2

You may try with this list of rules, in this order since your transformations are overlapping: rules = { Power[Subscript[X_,Subscript[a_,j_]], n_] :> Power[Subscript[\[Sigma],Subscript[a,j]], n]+ Power[Subscript[\[Mu],Subscript[a,j]], n], Times[rest1___, Subscript[X_,Subscript[a_,j_]], ...


2

I'd subsequently realized that I could simply just do gmultdist = EmpiricalDistribution[ {0.25, 0.25, 0.25, 0.25} -> { {0, 0}, {0, 1}, {1, 0}, {1, 1} } ] for the case of all equal weights. My original mistake was in "flipping" the order of -> initially in EmpiricalDistribution.


2

Just building on @ciao (@rasher) to deal with second part: c66 = TransformedDistribution[ a + b, {a, b} \[Distributed] DiscreteUniformDistribution[{{1, 6}, {1, 6}}]]; p66 = Probability[x == 11, x \[Distributed] c66]; c620 = TransformedDistribution[ a + b, {a, b} \[Distributed] DiscreteUniformDistribution[{{1, 6}, {1, 20}}]]; p620 = ...


1

Let $Z_1$ and $Z_2$ be independent Gaussian random variables with unit mean and unit standard deviation. Let $W = Z_1 Z_2$. Clearly $$\begin{eqnarray} F_W\left(w\right) &=& \Pr\left(W \leqslant w\right) = \Pr\left(W \leqslant w\right) = \Pr\left(Z_1 Z_2 \leqslant w\right) \\ &=& \mathbb{E}\left(\Pr\left(Z_1 Z_2 \leqslant w \mid ...


1

The weghts do not have to be equal or even numerical. $Version (* "10.2.0 for Mac OS X x86 (64-bit) (July 7, 2015)" *) Format[p[x_, y_]] := Subscript[p, Row[{x, y}]] assume = {Thread[0 <= {p[0, 0], p[0, 1], p[1, 0], p[1, 1]} <= 1], p[0, 0] + p[0, 1] + p[1, 0] + p[1, 1] == 1} // Flatten; gmultdist = EmpiricalDistribution[{p[0, 0], p[0, 1], ...


1

About 30X faster integration, no errors... Clear[x, x1, x2, x3, x4] muvec = ConstantArray[1/10, 4]; sigmat = IdentityMatrix[4]; pdf = PDF[MultinormalDistribution[muvec, sigmat], {x1, x2, x3, x4}] // FullSimplify Integrate[ 1*pdf, {x1, -Infinity, Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity, Infinity}, {x4, -Infinity, Infinity}] // ...


1

I just needed to do ClearAll[dist] first, as mfvonh pointed out in the comments.


1

It does appear something might have been tinkered with, or my recollection / documentation is in error. InverseFourierSequenceTransform[cf, t, -n, FourierParameters -> {1, 1}, Assumptions -> 0 < p < 1] // PiecewiseExpand properly recovers the PDF (PMF) for the GeometricDistribution case.


1

Just another way to calculate volume of hypersphere and then relevant probability using recursion: vs[n_] := Most@Nest[{#[[2]]/(#[[3]] + 1), 2 Pi #[[1]], #[[3]] + 1} &, {1, 2, 0}, n] v[n_] := vs[n][[1]] The probabilities: Grid[Prepend[{#1, #2, N@#2} & @@@ ({#, v[#]/2^#} & /@ Range[10]), Style[#, Bold] & /@ {"n", ...



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