# Tag Info

2

There is a Wolfram blog by Oleg Marichev and Michael Trott which has an accompanying CDF demonstration (that can be downloaded here). This CDF can be used to explore distributions and their multitude of properties. It isn't the palette you described (it also doesn't paste a function template as the original palette probably did) but it may be useful ...

0

You could do this as follows: ata = RandomVariate[NormalDistribution[0, 1], 100]; rc = RandomChoice[data, {100, 60}]; Needs["HypothesisTesting"]; Count[Times @@@ (Sign /@ (MeanCI /@ rc)), -1] Doing it 10 times: yielded (using Table): {69, 77, 96, 69, 69, 88, 93, 92, 94, 93}

4

fun[a_, b_, c_, x_, z_] := a (1 - z^2) Cos[x]^2 - (b z^2 + z - c) reg[a_, b_, c_] := ImplicitRegion[ fun[a, b, c, x, z] > 0 && -1 < z < 1 && 0 < x < 6, {x, z}] Visualizations (using triple {3,-2,2} used in another answer): rp = RegionPlot[reg[3, -2, -2]]; cp = ContourPlot[fun[3, -2, -2, x, z], {x, 0, 6}, {z, -1, 1}, ...

5

The function is given by fun[x_, z_] := a (1 - z^2) Cos[x]^2 - (b z^2 + z - c) We define a function that generates a random point in the x-z plane that satisfies fun[x, z] > 0: accept[a0_, b0_, c0_] := Block[{a = a0, b = b0, c = c0, x = RandomReal[{0, 6}], z = RandomReal[{-1, 1}]} , If[fun[x, z] > 0, {x, z}, accept[a, b, c]] ] Important ...

5

Lets create a "popuplation" of random numbers that are following a normal distribution and make the confidence level transparent: Needs["HypothesisTesting"]; pop = RandomVariate[ NormalDistribution[], 100]; SetOptions[ MeanCI, ConfidenceLevel -> 0.95 ]; (* or whatever is needed *) Now we draw samples which means we are sampling without replacement and ...

5

Here is your code rewritten to create the list of zeros and ones in a list, and then to count the number of ones: vstupnidata = RandomReal[NormalDistribution[0, 1], 100]; Needs["HypothesisTesting`"]; zeroOne = Table[vyb60 = MeanCI[RandomChoice[vstupnidata, 60]]; If[vyb60[[1]] < 0 \[And] vyb60[[2]] > 0, 1, 0], {i, 1, 100}] Total[zeroOne] 86

3

Assuming the two sets are related by some kind of geometric transformation you could use FindGeometricTransform for this. As a demonstration let's generate some random points: points = RandomReal[{0, 100}, {50, 2}]; Add a bit of noise and transform to get a second set: at = AffineTransform[{{0.9, 0.1}, {0.1, 0.9}}]; distPoints = at /@ (RandomReal[1] + # ...

0

This finds nearest matches and eliminates each pair from further consideration. data1 = Table[RandomReal[], {100}, {2}]; data2 = RandomVariate[NormalDistribution[0, .1], 2] + # & /@ RandomSample[data1, 80]; aligndata = NestWhile[ (pair = Position[#, Min[#]][[1]] &@ Outer[ EuclideanDistance , #[[1]], #[[2]], 1]; ...

12

the probability of a sequence of a given length being a word (as reported by DictionaryLookup): p[n_] := p[n] = (ToLowerCase /@ DictionaryLookup[StringExpression @@ ConstantArray[_, n]] // Union // Length)/26^n // N (* 27^n if spaces are to be included *) Show[{ ListLogPlot[Table[{n, p[n]}, {n, 3, 20}]], LogPlot[ 71625 ...

8

Of course the answer depends greatly on how you "randomly" choose the letters. Here is a Manipulate that reads in a source text, which is used to define the probability of occurrence of any given letter. It writes a short "poem" based on those probabilities. You can also look at probability "pairs" (how often a is followed by b, how often a is followed by c, ...

0

Assume the two data sets have five points each: data1 = Table[RandomReal[], {5}, {2}] data2 = Table[RandomReal[], {5}, {2}] EuclideanDistance @@ {Flatten[(Nearest @@ {data1, data2}), 1], data1} (* 0.819504 *) Why this works: Flatten[(Nearest @@ {data1, data2}), 1] finds the nearest point in data2 for each successive point in data1. Then ...

18

Just for comparing with Pillsy's answer, let's suppose we generate a uniformly random sequence of a-z and spacebar. SeedRandom[42]; n = 10^7; chars = Union[{" "}, CharacterRange["a", "z"]]; p = DictionaryLookup /@ StringSplit@ StringJoin@ RandomChoice[chars, n]; (Length@p - Count[p, {}])/ Length@p // N (* 0.0071783 *) 2558out of 356352 are "dictionary ...

13

Let's assume we're generating letters with the same frequency as they appear in the dictionary, in strings with lengths that have the same frequency as the lengths of words in the dictionary. To do this, first we need a list of words: In[1]:= words = DictionaryLookup[]; In[2]:= letters = (Values@# -> Keys@#) &@CharacterCounts[StringJoin[words]]; ...

3

J.M.'s comment: It evaluates the regularized incomplete beta function, which is built-in as BetaRegularized[], for appropriate arguments. As to what algorithm is being used to evaluate that… the docs only note that it uses hypergeometric function representations and continued fractions under the hood, and nothing more.

4

For a given function $p(x)$ to satisfy your requirement it needs to meet the constraints: $$\int_0^1 p(x)dx = 1; \quad p(0 \le x \le 1) \ge 0; \quad p(x < 0 \cup x > 1)=0$$ How to make it random is an open question. One approach is a function that passes through several random points in the unit square 0<=x<=1; 0<=y<=1, as well as ...

8

There are many ways to generate random distributions on the unit interval. I do not know of a function in Mathematica that will do that by itself, but it is straightforward to write a simple function that will. The approach presented here is based on random Bernstein polynomials, which in this context become random mixtures of beta distributions. Here is a ...

7

While the answers so far have covered a lot of ground already I have not seen EmpiricalDistribution. I would like to build upon this observation by providing a couple of general considerations that I have found to be useful when doing statistical experiments using Mathematica. What users of Mathematica may take for granted may surprise newcomers: You can ...

7

This documentation page spells out how EstimatedVariance is computed. It is the "squared sum of FitResiduals divided by the degrees of freedom $n-p$. A linear regression will also have an intercept term, in addition to terms corresponding to each of the predictor columns. For example, headings = ExampleData[{"Statistics", "FisherIris"}, "ColumnHeadings"]; ...

2

Here's a solution for i dice with j faces using IntegerPartitions and Permutations. dice = 2; faces = 6; range = Range[dice, dice*faces]; res1 = Flatten[Permutations /@ #, 1] & /@ (IntegerPartitions[#, {dice}, Range @ faces] & /@ range); len = Length /@ res1; pro1 = 1/faces^dice*len; Grid @ Join[ {{"Points", "Probability", ...

0

(* Model an unbiased six-sided dice throw *) dice = DiscreteUniformDistribution[{1, 6}]; (* generate random 2 N throws and compute probabilities of sum *) Sumdice[j_, num_] := Count[RandomVariate[dice, {num, 2}], _?(Total[#] == j &)]/num ListPlot[Table[{j, N[Sumdice[j, 10^5]]}, {j, 2, 12, 1}], Filling -> Axis] In case you want the ...

9

There are many ways you can do this, e.g. ri = RandomInteger[{1, 6}, {100, 2}]; SortBy[Normal@GroupBy[ri, Total, Length@#/100. &], First] yielding: {2 -> 0.01, 3 -> 0.05, 4 -> 0.11, 5 -> 0.08, 6 -> 0.13, 7 -> 0.12, 8 -> 0.17, 9 -> 0.14, 10 -> 0.11, 11 -> 0.07, 12 -> 0.01} rules linking sum to frequency. You can also exploit ...

4

dist = TransformedDistribution[x + y, { Distributed[x, DiscreteUniformDistribution[{1, 6}]], Distributed[y, DiscreteUniformDistribution[{1, 6}]]}]; SeedRandom[1] For small sample sizes, the match to the theoretical values is poor. data = Total /@ RandomInteger[{1, 6}, {100, 2}]; Show[ Histogram[data, {1.5, 12.5, 1}, "PDF", ...

10

In Mathematica it is natural to approach such a task with list operations and pattern matching. dice1 = RandomInteger[{1, 6}, 100]; dice2 = RandomInteger[{1, 6}, 100]; Count[dice1 + dice2, 2 | 3 | 4 | 5 | 6] You seem to be a very new beginner, since you are using x[i] and y[i] as if these are vectors, when they are in fact not, in Mathematica. Mathematica ...

4

You can use RandomVariate to sample from a DiscreteUniformDistribution and then add up the pairs, calculate the probability of the sums observed, and then extract the probabilities of interest. (#/100. & /@ Counts[Plus @@@ RandomVariate[ DiscreteUniformDistribution[{1, 6}], {100, 2}]] )[#] & /@ Range[2, 6] Hope this helps.

6

This might not even come close to the real distribution and I'm also not going to comment on the usefulness of this endeavor or the final result. I'll take your data as five points of a CDF assigning kind of arbitrary probability values to the maximum loss and maximum profit values data = {{-4305, 0.01}, {-1801, 0.25}, {4044, 0.5}, {4938, 0.75}, {6120, ...

1

Adapting @Silvia´s code (errr ... mostly copying it) data = Uncompress@Import["http://pastebin.com/raw.php?i=hkhuyvza"]; data1 = Rest@Transpose[Rescale /@ (Transpose@data)]; peakfunc[A_, μ_, σ_, x_] = A^2 E^(-((x - μ)^2/(2 σ^2))); Clear[model, modelvalue] model[data_, n_] := Module[{dataconfig, modelfunc, objfunc, fitvar, fitres}, dataconfig = {A[#], ...

3

You could do for example: int[al_?NumericQ, be_?NumericQ] := NIntegrate[(funcr[al, be, x] - piece[x])^2, {x, 0, 1}] nm = NMinimize[{int[al, be], al >= 1, be >= 1}, {al, be}] Plot[{piece@x, funcr[al, be, x] /. nm[[2]]}, {x, 0, 1}, PlotStyle -> {{Thickness[.01], Red}, {Dashed, Thickness[.01], Blue}}]

3

I am not quite following what you are trying to do with norm or max. The procedure I followed was to make some data from your fake empirical cumulative probability function. piece[x_] := Piecewise[{{x^3, 1 >= x >= 0}, {1, x > 1}}, 0]; data = Table[{x, piece[x]}, {x, 0, 1, 0.02}]; Copy and paste your "model" funcr[al_?NumericQ, be_?NumericQ, ...

2

Analytic approach: Manipulate[ SeedRandom["five"]; ListPointPlot3D[ RandomVariate[ TransformedDistribution[{a, b, c*a + (1 - c)*b}, {{a, b} \[Distributed] OrderDistribution[BinormalDistribution[r], {1, 2}]}], 10^3], PlotLabel -> Row[{"c = ", c, " | ", "r = ", r}]], {{c, 0.5}, 0, 1}, {{r, 0}, -.99, .99}]

4

Fit works using singular value decomposition. FindFit uses the same method for the linear least-squares case, the Levenberg–Marquardt method for nonlinear least-squares, and general FindMinimum methods for other norms. - source NonlinearModelFit allows fitting of weighted data, as J.M. commented Edit: The best fit parameters are a property of the ...

5

A common approach is to blank/mask out the signal and fit a polynomial to the remaining data. A problem to avoid here is overfitting, i.e. fitting some high-order polynomial to the noise structure. Taking the artifical data from Vitaliy's answer: f[x_] := Exp[-(x - 7)^2] + Exp[-(x + 5)^2] - .002 x^2 data = Table[{x, f[x] + .1 RandomReal[{-1, 1}]}, {x, ...

10

So imagine you do not know the background formula. This can be done in a beautiful way with FindFormula. Generate data: f[x_] := Exp[-(x - 7)^2] + Exp[-(x + 5)^2] - .002 x^2 data = Table[{x, f[x] + .1 RandomReal[{-1, 1}]}, {x, -15, 15, .1}]; Plot[f[x], {x, -15, 15}, PlotRange -> All, Epilog -> {Red, Point[data]}] Now use FindFormula to learn ...

6

Your provided data is very noisy. You can get more information from it if you filter it first. I will apply a LowpassFilter and a logarithmic transform on the $y$ values, and scale down the $x$ values. This usually helps the fitting algorithm. datat = Transpose[{#[[All, 1]]/1500, Log10[LowpassFilter[#[[All, 2]], .1]]} &@data]; ListPlot[datat, ...

4

If you know the number of Gaussians, you can proceed as follows. Here is data with a single Gaussian added to a quadratic with noise: mydata = Table[ {n, .01 n^2 + 40 PDF[NormalDistribution[10, 1], n] + 3 RandomReal[]}, {n, 1, 40}]; Here's a non-linear model of the assumed form but unknown constants: nlm = NonlinearModelFit[ mydata, {a n^2 + b ...

9

Based on the description you provided from the MATLAB documentation, corr2 is computed as $$\frac{\sum_m \sum_n (A_{mn} - \bar{A}) (B_{mn} - \bar{B})}{\sqrt{\left(\sum_m \sum_n (A_{mn} - \bar{A})^2\right) \left(\sum_m \sum_n (B_{mn} - \bar{B})^2\right)}}$$ Assuming that the mean2 function that gives the values of $\bar{A}$ and $\bar{B}$ does the ...

Top 50 recent answers are included