Tag Info

New answers tagged

1

Here are the modifications that need to be done on your plots h1 and h2 in order to flip them over the line y == x. If you look "under the hood" at the structure of these two plots by executing, for instance, FullForm@Normal@h1 you find that really there are only two objects, a Line and a Polygon. Both of these Heads take inputs which are lists of {x, y} ...


5

An exact symbolic solution can be obtained in the case when $\mu=0$, with arbitrary $\sigma$. We then have two independent $N(0,\sigma^2)$ random variables, each with pdf $f(x)$: The pdf of the product of two Normals can then be derived exactly as: ... where I am using the TransformProduct function from the mathStatica package for Mathematica. Here is ...


4

RandomVariate for BinomialDistribution[n,p] changes between methods depending on the value of Min[n*{p,1-p}]. What we're seeing here is that one of those methods is poorly optimized. Because of this thread, we've made some improvements which should improve speed when Min[n*{p,1-p}]<10. These will be in the next release of Mathematica. We'll also ...


8

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(Z_1 Z_2 \leqslant w\right) \\ &=& \mathbb{E}\left(\Pr\left(Z_1 Z_2 \leqslant w \mid Z_2\right) \right) \\ &=& ...


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), {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, Assumptions -> z ∈ Reals] and then Plot Plot[f[z], {z, -2, 2}, PlotRange -> All] To change the variances: f[z_] = Integrate[Exp[-x^2/(2 sigX^2)] Exp[-y^2/(2 sigY^2)] ...


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} *)


5

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}, ...


5

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, ...


0

You've learned a valuable lesson... pesky things those "densities" - they aren't born in isolation but together with the "measure" they are defined with so the whole mathematical object becomes invariant. "Moral of story: Transforming densities is always like a "change of variables" when integrating!


6

data = Import["/Users/roberthanlon/Downloads/test.xlsx"][[1]]; Dimensions[data] {6039, 2} Since the data consists of pairs of values, the distribution given by SmoothKernelDistribution[data] is for a bivariate distribution. K = SmoothKernelDistribution[data]; {xmin, xmax} = MinMax[data[[All, 1]]]; {ymin, ymax} = MinMax[data[[All, 2]]]; ...


3

You can even read the following How to | Import a Spreadsheet data = Import["/Users/xxx/Desktop/test.xlsx", {"Data", 1, All, 1}]; K = SmoothKernelDistribution[data]; Table[Plot[f[K, x], {x, -1000, 4000}, PlotLabel -> f], {f, {PDF, CDF}}] How to | Import a Spreadsheet The spreadsheet is included in the Wolfram Language documentation folder ...


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], ...


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 = ...


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] ...


1

I have now figured out the issue. It was because I was not including a Jacobian term in the likelihood $\frac{dW}{dZ}=\frac{Z^{1/\beta-1}}{\beta}$. After doing so, the log-likelihood becomes: $l = -(n/2)ln(2\pi) - (n/2)ln(\sigma^2) - n ln(\beta) + (1/\beta-1)\sum ln(Z) - (1/{2\sigma^2})\sum_{i=1}^n (Z_t^{1/\beta} - \rho Z_{t-1}^{1\beta} - (1-\rho) ...


1

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


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 ...


4

Here is an answer that does not use a 3rd party package and works for an arbitrary amount of Beta distributions. You can make use of a closed form for the product of n Beta distributions from the Handbook of Beta Distribution and Its Applications, Products and Linear Combinations, I. Products, B. Exact Distributions as found on page 57. This expresses a ...


2

The problem can indeed be solved explicitly for the product of n = 3 Beta-distributed variables and the explicit parameters of the OP. In part 1 I show only the results, and turn later, in part 2, to the details of calculation in Mathematica, part 3 is discussion. Part 1 Results The PDF of the Beta distribution is given by f[x_, a_, b_] = ...


5

Let random variable $X_i \sim Beta(a_i,b_i)$, with pdf $f_i(x_i)$. The OP is interested in 3 specific parameter combinations: The pdf of $Y = X_2 X_3$, say $g(y)$, is: where I am using the TransformProduct function from the mathStatica package for Mathematica, and where domain[g] = {y,0,1}. The pdf of $Z = X_1 X_2 X_3 = Y* X_1$, say $h(z)$, is 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 ...


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, ...


5

From what I can tell you are recalculating the transformed distribution too often in your plot. Calculate and store the resulting PDF once and then use it for your plots. tpdf = PDF[ TransformedDistribution[ u v, {u \[Distributed] BetaDistribution[1, 1], v \[Distributed] BetaDistribution[3/2, 1/2]}], x] Once you have tpdf your plot will return ...


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.


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.


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, ...



Top 50 recent answers are included