Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have an expected value say 5(minimum) or 6(minimum).

Then I have 4 values [3, 10, 6, 8]

I would like to compute the percentage on how far the 4 values are from the expected value in terms of percentage. Given 100% means they are all within the minimum and maximum and the farther they are from the expected the lower the percentage would be.

I was looking for a mathematical way of computing this. One way is to assign true or false score for each. Meaning either they match or not the minimum or maximum value.

[3(0.0), 10(0.0), 6(1.0), 8(0.0)] would give 25%

But this solution is too crude because I want to give more fine grained computation for how far I am from the expected value.

[3(0.0), 10(0.0), 6(1.0), 8(0.0)] would give X% [1(0.0), 10(0.0), 6(1.0), 9(0.0)] would give Y%

Y% should be lower than X% since their value deviates farther from the mean than X%.

I do have a boundary of expected values, 1 to 30. I tried to read on statistics like standard deviation but it is the deviation from the mean. Even If i change it to deviation from expected value, How do I get percentage of how far is it from expected value?

Updated: I guess I already got an idea on this one. Let say there are N=20 available number to be taken. Then there are X=4 who would share this 20 slots. What I will do is get the average which is A=N/X=5. So I would compute for the summation of the difference of each item from the average. S=sum(abs(Ni-A)) I get the sum of the difference from the maximum.

The percentage would be 1-(S/N)

share|improve this question
    
FYI the mean is a synonym for expected value –  Neil G Dec 26 '10 at 5:43
1  
@Neil G: It's not a $synomym$, because it can also mean the average of a set of data points. –  TonyK Dec 26 '10 at 15:14
    
What you need is the standard deviation. –  Raskolnikov Dec 26 '10 at 18:22
    
@Raskolnikov could you specify in an example how this is achieve via standard deviation. –  Nassign Dec 27 '10 at 9:20

2 Answers 2

Do you mean 5 (minimum) to 6 (maximum)? You could calculate how many ranges away each item is. So 3 would get a score of 2 (from being 2 away from 5). 10 would get a score of 4 (10-6). 6 would get a score of 0 for being in range and 8 would get a score of 2. This doesn't tell you what percentage are in range, but it does tell you how far out the others are. Then if your range was 5 to 7 the scores would be 1 for 3, 3/2 for 10, and 1/2 for 8. Maybe you need both figures.

share|improve this answer
    
Ross, where did you get the divisor of 2 in your last statement? you said 3/2 for 10. what does 2 mean? –  Nassign Oct 26 '10 at 5:06
    
When I expanded the expected range from 5-6 to 5-7, I represented the out-of-range values by how many ranges they were out. It all depends what you want. –  Ross Millikan Oct 26 '10 at 12:44
    
@Nassign. You did not answer Ross's question: Do you mean....? If there is a mistake in your question, you should correct it. –  TCL Dec 27 '10 at 12:44

Say you have $n$ data points $\{x_1,x_2,x_3,\ldots,x_n\}$. You have a range of values with which to compare them $[a,b]$. Then, as Ross suggests, I would also assign a score to this set of data points. I would base it on the standard deviation.

Values that fall inside the interval get score zero, values $x_k$ that fall outside the interval get score $\min((x_k-a)^2,(x_k-b)^2)$. But if you prefer to take just absolute deviations like Ross, just adapt the formula. Then simply add all scores for all the data points to obtain one score for the entire set of data points.

The lower the score, the closer the points are to the interval, the higher the farther they lie out. If you dispose of several data sets with different scores, you can define percentage deviations by looking at what percentage of data have a lower score than the data set you are examining.

I made a small R script that illustrates the idea:

n=1000;
size=10;
big<-matrix(rnorm(n,0,1),n%/%size,size);
liminf=-1;
limsup=1;
z=rep(0,length(big[,1]);
perc=z;
for (k in 1:length(big[,1]))
{ z[k]<-sum((big[k, big[k,]<liminf]-liminf)^2)+sum((big[k,big[k,]>limsup]-limsup)^2) ; }
mat<-matrix(c(1,2),1,2);
layout(mat);
hist(z,10,main="Score histogram");
for (k in 1:length(big[,1]))
{ perc[k]=length(z[z<z[k]])/length(z); }
plot(sort(z),sort(perc),main="Cumulative plot");

It makes a big matrix of 100 rows of each ten columns. Each row is to be interpreted as one data set. The data have been sampled from a random normal distribution, but you can adapt to any type of data of course. Then, I calculate the score of each row with respect to a chosen interval, here the interval $[-1,1]$. I plotted a score histogram as a bonus. After that, I compute for each score how many percent of the scores is smaller than that score. That's what the perc is for. I also plotted the cumulative function for the scores based on the computed function perc.

share|improve this answer

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.