Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have data that reflects the arrival time of a flight. {3, -2, 16, 13, -6, 5, 4, -7, 7, 0……..n} this is for 8:45am and has 150 elements "arrivals" The positive values represent the time in minutes past the planned time,{“late”} and the negative, is before planned time {“early”} My question, I would like to find the time of arrival with the highest probability. Can I use this data as is?

share|improve this question
    
Is your question related to Mathematica (TM)? If not, you're in the wrong site –  belisarius Feb 23 '13 at 1:08
    
Yes this is a question directed to mathematica. –  Bob Brooks Feb 23 '13 at 1:24
1  
Histogram[data,Automatic,"Probability"] seems like a good start. To say anything about highest probability you need to make some assumptions about the underlying distributions. You can try to fit various distributions to the data. –  ssch Feb 23 '13 at 1:33
2  
On a related note, anyone know how DistributionFitTest is supposed to be interpreted? sets = 100; size = 10000; data = RandomVariate[NormalDistribution[], {sets, size}]; Histogram[DistributionFitTest[#, Automatic] & /@ data] It's all over the place –  ssch Feb 23 '13 at 1:53
1  
@ssch, As far as I understand DistributionFitTest gives you back the p-value from the test which is going to vary for each set but most of the results of the actual test are what you expect sets=100;size=10000;data=RandomVariate[NormalDistribution[x,{sets,size}];Tally[‌​(DistributionFitTest[#,Automatic,"ShortTestConclusion"] & /@ data)] –  Martin John Hadley Feb 23 '13 at 2:20
show 8 more comments

1 Answer

up vote 3 down vote accepted

For the sake of giving a (hopefully) useful answer.

Lets generate 150 arrival times where negative values indicate early and positive times indicate late arrivals. Here I'm assuming that people are as likely to be late as early and the distribution of arrival times is BinomialDistribution[20, 1/2]. This further assumes that people tend to be about 10 minutes early or 10 minutes late.

SeedRandom[1];
arrival = 
 RandomChoice[{-1, 1}, 150]*
  RandomVariate[BinomialDistribution[20, 1/2], 150];

Now there are a number of things available to us in Mathematica for working with this data.

Lets compute the expected arrival time.

Expectation[a, a \[Distributed] arrival]

(* -(109/75) *)

Or we could say, what is the probability someone is late?

Probability[a > 0, a \[Distributed] arrival]

(* 13/30 *)

We can estimate distributions from the data. Here a mixture of normals is used which is a little silly given that the data is discrete but normal is known to be a reasonable approximation to the binomial distribution with large enough samples and we expect a bimodal distribution given the setup.

 est = EstimatedDistribution[arrival, 
 MixtureDistribution[{1/2, 1/2}, {NormalDistribution[a, b], 
   NormalDistribution[c, d]}]]

(* MixtureDistribution[{1/2, 1/2}, {NormalDistribution[9.75385, 2.15571], 
  NormalDistribution[-10.0235, 2.35635]}] *)

We can plot all sorts of things and assess the goodness of fit to our chosen distribution.

Show[Plot[PDF[est, x], {x, -25, 25}], SmoothHistogram[arrival]]

enter image description here

We should keep in mind here that the p-value will probably be larger than it should be since I've estimated the distribution from the data first...

DistributionFitTest[arrival, est]

(* 0.107467 *)

We can always check further with a QuantilePlotwhich claims it doesn't fit so well in the body of the distribution...

QuantilePlot[arrival, est]

enter image description here

The bottom line is that there is nothing special about negative arrival times as far as Mathematica is concerned. It is happy to work with them just like any other data.

share|improve this answer
    
Thank you @AndyRoss, I think this will do just fine! –  Bob Brooks Feb 23 '13 at 20:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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