# Tag Info

12

The multinomial distribution is an option: sampleSize = 1; n = 40; p = {1/4, 1/4, 1/4, 1/4}; RandomVariate[MultinomialDistribution[n, p], sampleSize] Out (for example): {{14, 11, 10, 5}} Explanation: n is the number of layers. p contains the probabilities of each type of rock. The Multinomial distribution selects one type of rock n times, according ...

10

The Kolmogorov-Smirnov test is used to test for the equality of an empirical and a theoretical distribution. The critical value is not specific to a certain distribution and, for sufficiently large samples, can be calculated as follows (see Wikipedia): pr[x_] := (Sqrt[2*Pi]/x)*Sum[E^((-(2*k - 1)^2)*(Pi^2/(8*x^2))), {k, 1, 100}] crit[α_, n_] := (x /. ...

10

Even if there wasn't one, there is one now: I think you've just written it yourself :-) summary[dset_] := Through[{Min, Quantile[#, .25] &, Median, Quantile[#, .75] &, Max}[dset]] SeedRandom[1234] data = RandomInteger[{0, 100}, 100]; summary[data] (* Out: {0, 18, 91/2, 66, 98} *)

8

I understood it. The argument of the ProbabilityDistribution should be properly normalized. It would be actually useful if mathematica produced some kind of error message in this example. So the correct code should be: norm = NIntegrate[1/(x^2 + 1), {x, -5, 5}]; dis = ProbabilityDistribution[(1/(x^2 + 1))/norm, {x, -5, 5}]; data = RandomVariate[dis, 10^4]; ...

8

You can use RandomChoice to pick from the 4 rock types with different probabilities. n = 40; types = {1, 2, 3, 4}; probs = {60, 25, 10, 5}; model := Counts[RandomChoice[probs -> types, n]] /@ types /. _Missing -> 0 population = Table[model, 100]; N @ Mean[population] (* {24.27, 9.63, 4.13, 1.97} *)

8

If by "equivalent" you mean having the same mean and standard deviation: NormalDistribution[12, 3.2] What is the relationship between the mean and variance of a Weibull distribution and its parameters $\alpha$ and $\beta$? Mean[WeibullDistribution[α, β]] $\beta \Gamma \left(1+\frac{1}{\alpha}\right)$ Variance[WeibullDistribution[α, β]] $\beta ^2 ... 8 Here is a fairly fast code snippet. The idea is to place three demarcators in 43 slots (in general: n+k-1 slots, k-1 demarcators). Then the count between jth and j+1th is the number that goes in the j+1th position of the result, where j runs from 0 to k (and there is no 0th position in the result). sample = Compile[{{total, _Integer}, {len, _Integer}, {n, ... 7 Simon showed the appropriate application of RandomChoice. To expand on this, you can also visualize the different layers in the following manner: n = 40; types = {1, 2, 3, 4}; probs = {60, 25, 10, 5}; model := RandomChoice[probs -> types, n] GraphicsRow@ (ArrayPlot[#, ImageSize -> 15, ColorRules -> {1 -> Brown, 2 -> Gray, 3 -> Black, ... 7 This is one of my few gripes re: an otherwise quite nice probability functionality. Sometimes, performance is inexplicably poor. Usually, trivial manual transformation/intervention can get the results desired speedily, e.g., your example cases: ClearAll["Global`*"] dist = MultivariateHypergeometricDistribution[5, ConstantArray[2, 10]]; PDF[dist, ... 7 You have two related problems. The first is that NProbability finds the probability of a condition being met. However, your condition x - y == 0 is only true when x and y are exactly equal, which happens with probability zero. Fixing the condition to y > x (and using the default Method), we get a probability of: NProbability[ y > x, { x ... 5 You probably want something like byTask = GatherBy[data, First][[All, All, 2]]; Tr /@ ((# - Mean@#)^2/Length@# & /@ byTask) (* {3834/169, 4690/169, 250/9, 196/5, 397/12, 2482/121} *) 5 As far as I see, the problem is (as you already wrote), that MeanResidualLife takes a long time to compute, even for a single evaluation. Now, the FindMinimum or similar functions try to find a minimum to the function. Finding a minimum requires either to set the first derivative of the function zero and solve for a solution. Since your function is quite ... 5 Something like this perhaps. tsm = TimeSeriesModelFit[data]; ListLinePlot[{tsm["TemporalData"], TimeSeriesForecast[Normal[tsm], data, {6}, Method -> "Kalman"]}] 5 GaussianRandomField is a special case. More generally, what is required is fast code for the (inverse) Spherical Harmonic Transform (SHT), which will work for any coefficients$a_{l,m}$. SHTns is a high performance library for Spherical Harmonic Transform written in C and so should be straightforward to link in using MathLink. It would be very nice if this ... 4 A part from efficiency, I noticed that with the definition below, lmax >= 64 works: Clear[field]; field[θ_, ϕ_] := Chop@ Total[ Table[ alms[l, m] SphericalHarmonicY[l, m, θ, ϕ], {l, 0, lmax}, {m, -l, l} ] , 2 ]; nn = 4.; dat = ParallelTable[ field[θ, ϕ], {θ, 0, Pi, Pi/nn}, ... 4 Although @ciao's solution gets you to the answer, I would like to offer perhaps another angle at it. Given a tuple$\{X_1, X_2, \ldots, X_n\}$that follows a multivariate hypergeometric distribution with parameters$N$,$\{M_1, \ldots, M_n\}$, the tuple$\{X_1, X_2, \sum_{k=3}^n X_k \}$also follows a multivariate hypergeometric with parameters$N\$ and ...

4

I think GatherBy (docs) is what you are looking for. The following expression gathers the data in the plot in separate sublists according to the value of the second element in each sublist, which in your case is the month name (the same results could be obtained with the third element, i.e. the month number). I then generated the chart labels from the ...

3

Patrick Stevens gave the following expression in a comment: Expectation[ (Z1 + Z2 + Z3 + Z4)^4, {Z1, Z2, Z3, Z4} \[Distributed] MultinormalDistribution[{0, 0, 0, 0}, Table[p[i, j], {i, 1, 4}, {j, 1, 4}]]] It solves my problem.

3

s = GatherBy[First@Cases[FullForm@plot3, Point[h___] :> h, Infinity], Function[{u}, MemberQ[#, u[[1]]] & /@ {x, y, z}]] plot3 /. Point[__] :> MapThread[{#1, Point@#2} &, {{Red, Blue, Green}, s}]

2

So, I had a look at that old version of my notebook and I found it too specific. I copy here part of what was the documentation of my Override.m package. It's more general. (I'll spare you the code required to add options...) Here we go. It's easy to redefine a built-in procedure so that it can call itself without incurring in an infinite recursion. The ...

2

In your linked post DrBubbles seemed to have the same issue. I'm not sure about the underlying theory and the link he posted to seems to be proprietary. Your error propagation seemed fine and I was getting the same thing you were. I guess what I would do would be to take the root sum square of the two errors and use that as an effective y error. Then find ...

2

Some time ago I programmed such a function, RecordsSummary, inspired by R's summary. Here is an example of its usage: Census data summary . As the name implies, it is assumed that we have a list of records, all with the same length, and we want the columns to be summarized. (Each record is a row.) You can get the package MathematicaForPredictionUtilities.m ...

2

SemanticImport can help you easily generate a Dataset that is similar to R's data frames. lottery = Import["http://lib.stat.cmu.edu/DASL/Datafiles/DraftLottery.html", "XMLObject"]; First @ Cases[lottery, XMLElement["pre", _, {d_}] :> d, Infinity]; SemanticImportString[%]; Query[GroupBy[#Month &], All, "Draft_No."] @ %; BoxWhiskerChart[%, ...

2

Here's my study of various approaches to generating these tuples. Tl;dr: all the code can be easily copy-pasted into a new notebook by running this line: NotebookPut@ ImportString[ Uncompress@ FromCharacterCode@ Flatten@ImageData[Import["http://i.imgur.com/mGkmbGm.png"], "Byte"], "NB"] First I deal with summing three integers up to ten. ...

1

Just another way: ranf[sum_, n_, num_] := With[{r = Join @@ (Permutations /@ PadLeft[IntegerPartitions[sum, n]])}, RandomChoice[r, num]] For example showing relationship to MultinomialDistribution: EstimatedDistribution[ranf[40, 4, 1000000], MultinomialDistribution[40, {a, b, c, d}]] yields: MultinomialDistribution[40, {0.249981, 0.249976, ...

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