Tag Info

New answers tagged

2

I think there are a few complications to handle. From the code you proposed, it seems to me that you want to run one-way ANOVA on the two subsets obtained by grouping the data according to the value of the "var" key in the full dataset. However, to carry out one-way analysis, ANOVA accepts input as a list of lists of two elements, not three, as you can see ...


6

ClearAll[tF] SeedRandom[10] n = 100; sample = Sort[Sin[Pi*RandomVariate[UniformDistribution[{0, 1}], n]]]; dist = EmpiricalDistribution[sample]; Use tF to define a custom ProbabilityDistribution: tF[y_] := 2/Pi*ArcSin[y] tfdist = ProbabilityDistribution[{"CDF", tF[x]}, {x, 0, 1}]; Row[Plot[Evaluate[#[tfdist, x]], {x, 0, 1}, Filling -> Axis, ...


5

Also fixing your code... n=30; TF[y_] = 2/Pi*ArcSin[y]; SeedRandom[10]; sample = Sort[Sin[Pi*RandomVariate[UniformDistribution[{0, 1}], n]]]; d = EmpiricalDistribution[sample]; EF = CDF[d, x]; To get the max. difference, I tried NMaximize and others, but didn't work. The one that worked for me was this: X = NArgMax[{Abs[EF - TF[x]], 0 < x < 1}, x] ...


2

You had a few oddities in your syntax. If you want to define TF as a function of $y$, you had best use SetDelayed (:=) instead of set. Take a look at the documentation of search this site on this point. The constant $\pi$ is Pi in Mathematica, note the uppercase letter. $n$ was not defined in your code. I am arbitrarily using $100$ data points in the ...


3

sample = RandomVariate[NormalDistribution[], 200]; histogramdata = Histogram[sample, {Sort@RandomReal[{-4, 4}, 20]}, "PDF"]; h = Cases[histogramdata, StatusArea[_, x_] :> x, -1]; w = Cases[histogramdata, RectangleBox[{x_, _}, {y_, _} | NCache[{y_, _}, _], __] :> Mean@{x, y}, -1]; Show[histogramdata, ListLinePlot[Transpose[{w, h}]]]


7

Update: An alternative approach is to extract coordinates of the Rectangles and use Show similar to the approach @Algohi's answer. We define an auxiliary function lF to generate the coordinates for the line we need, and use it in the function showF that takes an Histogram as input and Shows it together with a line joining the midpoints of the rectangle ...


4

Here is another way: histogram := Histogram[ RandomVariate[NormalDistribution[0, 1], 200], Automatic, Function[{bins, counts}, Sow[bins, "bins"]; Sow[counts, "counts"]] ] {g, bins} = Reap[histogram]; Show[ g, Graphics@Line@MapThread[{Mean[#], #2} &, Flatten[bins, 1]] ]


5

Your histogram doesn't have regular binning, so you will want to specify how you want the binning done in your question. To get you started, however, here is an idea with regular binning. Otherwise you could adapt the code from your previous question on uneven binning to this problem. SeedRandom[10] sample = RandomVariate[NormalDistribution[], 200]; ...


0

It makes sense that Quantile shouldn't work with any multivariate distributions. Effectively Quantile uses the Inverse CDF which cannot exist for multivariate distributions, since you can produce an infinite number of rectangles or other shapes around the median (or mean) point which contain $q$% of the probability mass. Inverse CDFs only can exist in 1D ...


6

SeedRandom[123] n = 15; a = 0; b = 2; data = Sort[Sin[RandomVariate[UniformDistribution[{a, b}], n]]]; Yo can also specify the PlotStyle setting to add Point primitives to Lines: Plot[CDF[EmpiricalDistribution[data], y], {y, 0, 1}, Filling -> None, PlotStyle -> ({Orange, Thick, #, PointSize[.0125], Point[#[[1]]] & @@ #} &), ImageSize ...


5

Perhaps you could add point to each line segment after the plot is generated: SeedRandom[4]; data = Sort[Sin[2*RandomVariate[UniformDistribution[{0, 1}], 12] + 0]]; ScriptCapitalD = EmpiricalDistribution[data]; Plot[CDF[ScriptCapitalD, x], {x, 0, 1}, PlotStyle -> Orange, ExclusionsStyle -> None, Frame -> True] /. Line[p_] :> ...


0

Here is a style for such plots that I have used before: makeBinomialPlot[n_, p_] := Module[ {scale = .9}, Show[ ListPlot[ Table[ {k, PDF[BinomialDistribution[n, p], k]}, {k, 0, n} ], Filling -> Axis, FillingStyle -> Black, PlotStyle -> PointSize[.015], PlotRange -> All, Epilog -> {Inset[ ...


2

You can also use the options GridLines and Method -> {"GridLinesInFront" -> True}: SeedRandom[1]; grades = RandomInteger[{30, RandomInteger[{50, 100}]}, {7, 10}]; gridline = Median[Join @@ grades]; classes = {"Mathematics", "History", "English", "Chemistry", "Law", "Physics", "Statistics"}; BoxWhiskerChart[grades, "Outliers", ChartLabels -> ...


1

After looking about online a bit more I found the Epilog option. To draw my lines I have added Epilog->{Directive[{Thick, Red, Dashed}], Line[{{61,0},{61,10}}]} to the end of the BoxWhiskerChart environment. NB. The 10 in {60,10} is the height of the plot with respect to the bars. There are 9 bars plus half either side of the top two, hence 10.


0

If n is a list containing the sample sizes (all elements equaling 50 in your case) for a binomial variable, then you can account for potentially varying sample sizes by including the Weight option in the following manner: Weights -> 1/Sqrt[n] This could be made much more explicit in the documentation. A more complete example might be model = ...


1

Here's how to interpret statistical significance, here illustrated for a $\chi^2$ distribution: Such a distribution tells you the expected probability of finding a value of $x$ as the sum of squares of values chosen from $n$ univariate Gaussian distributions (where we call $n$ the degrees of freedom). Of course, the value of $x$ can never be negative. The ...


11

I will give you two similar methods. Simple Gaussian Threshold The simplest way is to remove the moving mean of the data, then compute its standard deviation ($\sigma$), then pick a level at which you want to reject the data, say at 1%, so you can remove any points that vary more than $ 3\times \sigma$ . If you know how the data is distributed about its ...


12

The executive summary You can use the built-in Ellipsoid function directly with your calculated mean and covariance. For 95% confidence, use: Ellipsoid[mean, 6 cov] That expression returns an Ellipsoid object that you can visualize as an Epilog to a ListPlot, or as an argument to Graphics (further formatting below). Ellipsoids for other common critical ...


6

The moving median is hardly affected at all by a few outliers, this can be used to identify the outliers. newData = Select[Transpose[{ data2[[10 ;;]], MovingMedian[data2, 10] }], Abs[Subtract @@ #] < 1 &] // Transpose; ListPlot[newData, PlotRange -> Full] In this piece of code 10 and 1 are arbitrarily chosen numbers that you ...


4

This is a problem known as finding moments of moments. In this case, we seek the covariance (i.e. the $\mu_{1,1}$ central moment) of various sample moments. The modus operandi for solving such problems is to work with power sum notation $s_r$, namely: $$s_r = \sum_{i=1}^n X_i^r$$ In this case, you are interested in the sample mean $ = \frac{s_1}{n}$, and ...



Top 50 recent answers are included