8
$\begingroup$

I am processing a data when I encountered this problem. I use the way of plotting the "normal probability plot" to show the result

The list I have is:

t1={0.0330584, 0.0288738, 0.0303384, 0.0330584, 0.034523, 0.0311753, 
0.029083, 0.0280369, 0.0332676, 0.0334768, 0.0338953, 0.0311753, 
0.0305476, 0.0332676, 0.0269907, 0.0332676, 0.0278276, 0.0261538, 
0.0286645, 0.0311753}

I want to use the following code to get the "Normal score" to shown if t1 is obeying normal distribution.

edist = EstimatedDistribution[t1, NormalDistribution[\[Mu],\[Sigma]]]

ListPlot[Transpose[{t1, 
     InverseCDF[edist, (Ordering[t1] + 1.0/6)/(
      Length@t1 + 1/3)]}], Joined -> False, PlotRange -> All, 
   FrameLabel -> (Style[#, 22] & /@ {"Normal Score", "Data"})]

But the function is not giving me the correct result.

enter image description here

So in Excel, the function RANK() can give the ordering of a certain value in a list. If there are two elements with same value, they will have same ordering after RANK() is applied. But in Mathematica, the function Ordering[] will give different value for same valued element. Is there another function can do this task?

What I used to do with Excel

When I use Excel to process it, I use two functions in Excel: RANK() and COUNT() the E column is obtained by

       (RANK(C1,$C$1:$C$20)+1/6)/(COUNT(C1,$C$1:$C$20)+1/3)

Then, I use =NORMSINV(E1) to get the final value of F column

After that, I can plot the C column and F column to shown the value of C column is obeying Normal distribution(whether if they are forming a line).

enter image description here

$\endgroup$
  • $\begingroup$ The problem is I don't know if there is functions in Mathematica can reproduce the results of the function RANK() and NORMSINV() in Excel. $\endgroup$ – BNHSX Dec 17 '15 at 1:40
  • $\begingroup$ Also, is there better ways to shown if my data obeys Normal Distribution? $\endgroup$ – BNHSX Dec 17 '15 at 1:41
7
$\begingroup$

I think you are looking for a QuantilePlot

QuantilePlot[t1]

enter image description here

There are others as well. Have a look at the Distribution Fits section Statistical Visualisation guide.

Hope this helps.

$\endgroup$
6
$\begingroup$

Use DistributionFitTest to test whether data is normally distributed. A small p-value suggests that it is unlikely that the data is normally distributed.

t1 = {0.0330584, 0.0288738, 0.0303384, 0.0330584, 0.034523, 0.0311753, 
   0.029083, 0.0280369, 0.0332676, 0.0334768, 0.0338953, 0.0311753, 0.0305476,
    0.0332676, 0.0269907, 0.0332676, 0.0278276, 0.0261538, 0.0286645, 
   0.0311753};

dft = DistributionFitTest[t1, Automatic, "HypothesisTestData"];

dft["TestDataTable", All]

enter image description here

edist = EstimatedDistribution[t1, NormalDistribution[μ, σ]];

{μ, σ} = List @@ edist;

Show[
 Histogram[t1, Automatic, "PDF"],
 SmoothHistogram[t1, PlotStyle -> Thick],
 Plot[PDF[edist, x], {x, μ - 3 σ, μ + 3 σ},
  PlotStyle -> Red]]

enter image description here

$\endgroup$
2
$\begingroup$

To get a quick visual peek at the distribution of the data, we can do:

GraphicsRow[Table[
  Show[
    Histogram[Sort[(t1 - Mean@t1)/StandardDeviation@t1], k, "Probability"]
    , Plot[PDF[NormalDistribution[0, 1], x], {x, -5, 5}]
  ]
  , {k, 5, 15, 5]

resulting in

enter image description here

It doesn't look all that normal, but the dataset is small, so of course it's hard to tell. Probably a real statistics test as mentioned in this answer to the question is more useful.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.