wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> medium >> Comparison of fractions
(Message started by: hoogle on Nov 29th, 2008, 11:32pm)

Title: Comparison of fractions
Post by hoogle on Nov 29th, 2008, 11:32pm
You are supposed to compare two a/b and c/d.   (a<=b and c<=d)

Think of fractions in this way, numerator is the number of good reviews received for a movie and denominator is the total number of reviews received. However, do not compare the exact values of fractions. Ex:Though  6/7 is less than 1/1 our comparison function should return 6/7 as a greater fraction because 6 out of 7 rated the movie as a good one.


I have a solution but I don't know if it is a good one:

.[hide] Every fraction a/b is transformed to ab/(b-a) (for b!=a) and that value is compared . This gives importance to both the value of fraction and denominator also[/hide]

Can anyone think of other function to compare the fractions.

Any help would be appreciated

Title: Re: Comparison of fractions
Post by Grimbal on Nov 30th, 2008, 1:12pm
It does not seem good at all.  The fact that it doesn't give a reply for a=b should raise suspicion.

8/10 should be better than 30/100.  But ab/(b-a) is 40 in the first case and 42 in the second.

I would say that comparing the numerical value of the fraction is a good measure for comparison.

Maybe if scores start at 1 (as worst score), then (a-1)/(b-1) could be a better measure.  2/3 and 3/5 would both mean the score in the middle and evaluate to 1/2.
edit: that would be if we have one evaluation rated between 1 and 5 for instance.

Title: Re: Comparison of fractions
Post by hoogle on Nov 30th, 2008, 1:18pm

Quote:
I would say that comparing the numerical value of the fraction is a good measure for comparison.


The problem with this approach is 1/1 will be given more weightage than 8/9 or something similar.

That is the reason I want to give some importance to denominator also....That is the reason I came up with that solution ab/(b-a). This gives importance to numerator and denomiator(a*b) and also it wants difference between them to be minimum(b-a)

ab/(b-a).... May be we can raise power of a in the numerator to solve the problem that occurs with the cases like 8/10 and 30/100....


Main point here is to give importance to denominator also

Title: Re: Comparison of fractions
Post by towr on Nov 30th, 2008, 1:18pm
Maybe subtract the standard deviation from the mean (fraction)
Of course that presumes that 2/4 is different (and better) than 1/2; 2 out of 4 positive votes is better than 1 out of 2 positive votes. At least if you're risk-averse.

So we get a/b -  (1-a/b) http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gif(a/(b-1))

[edit]Maybe a bit pessimistic, since it can give a score below 0, and b=1 is problematic. But the statistical approach is nice, imo.[/edit]

Title: Re: Comparison of fractions
Post by hoogle on Nov 30th, 2008, 1:28pm
@towr

I can understand that this works by substituting numbers for a and b.

Can you give an explanation why your approach works better than ordinary comparison of fractions' values?



Title: Re: Comparison of fractions
Post by hoogle on Nov 30th, 2008, 1:30pm
@towr

What is standard deviation and mean of a fraction?



Title: Re: Comparison of fractions
Post by towr on Nov 30th, 2008, 1:36pm

on 11/30/08 at 13:28:02, hoogle wrote:
I can understand that this works by substituting numbers for a and b.

Can you give an explanation why your approach works better than ordinary comparison of fractions' values?
I'm not certain it does work better. However, it has the advantage of meaning something; there is an interpretation to what you're doing.
One problem however is that 1/1 and 2/2 still compare equal, while the latter (I feel) should rate higher.


on 11/30/08 at 13:30:27, hoogle wrote:
What is standard deviation and mean of a fraction?
There isn't one. But if you consider the fraction as the result of sampling, where a/b means that you have a times the value of 1 and (b-a) times the value of 0; then you can just apply statistics.

The mean then becomes [a*1+(b-a)*0]/[a+(b-a)]=a/b
And the standard deviation is http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gif( [a*(1-a/b)^2 +(b-a)*(0-a/b)^2]/[a+(b-a)-1]) = a/b - http://www.ocf.berkeley.edu/~wwu/YaBBImages/symbols/surd.gif[(a-a2/b)/(b-1)]  Which actually doesn't correspond to what I did before, so there's an error in my previous post.

Title: Re: Comparison of fractions
Post by hoogle on Nov 30th, 2008, 1:43pm
According to the formula 3/3 will have higher value than 2/2 because of the term sqrt(a/(b-1)).

SO the formula seems to work well

Title: Re: Comparison of fractions
Post by towr on Nov 30th, 2008, 1:46pm

on 11/30/08 at 13:43:41, hoogle wrote:
According to the formula 3/3 will have higher value than 2/2 because of the term sqrt(a/(b-1)).
No it won't because you multiply that term by 0.

Title: Re: Comparison of fractions
Post by hoogle on Nov 30th, 2008, 1:47pm
I dont quite understand why is the denominator, while calculating standard deviation,a+(b-a)-1 instead of a+(b-a)

Title: Re: Comparison of fractions
Post by towr on Nov 30th, 2008, 1:54pm

on 11/30/08 at 13:47:47, hoogle wrote:
I dont quite understand why is the denominator, while calculating standard deviation,a+(b-a)-1 instead of a+(b-a)
To make it an unbiased estimator (http://en.wikipedia.org/wiki/Bias_of_an_estimator).

Anyway, looking at how the function works out, it has very bad properties. It rates 1/(5+) higher that 1/4, to name one of the worse properties.

You might be better off simply taking a/(b+1)

Title: Re: Comparison of fractions
Post by Grimbal on Nov 30th, 2008, 2:38pm
What about (a+1)/(b+2)?  It gives 0.5 for 0 reviews, makes 0/n decrease with n and n/n increase with n.

Title: Re: Comparison of fractions
Post by Eigenray on Nov 30th, 2008, 5:12pm

on 11/30/08 at 14:38:30, Grimbal wrote:
What about (a+1)/(b+2)?  It gives 0.5 for 0 reviews, makes 0/n decrease with n and n/n increase with n.

I was going to suggest the following: think of a/b as representing a occurrences out of b trials of an event with probability p.  If p has a uniform [0,1] prior distribution, then the posterior distribution of p has density
P(p=x | a/b) = (b+1) C(b,a) * xa(1-x)b-a,
and then take the expected value E(p | a/b).  But I see you've beaten me to it ;)

Title: Re: Comparison of fractions
Post by hoogle on Nov 30th, 2008, 10:16pm
What is the difference between a/(b+1) and (a+1)/b+2).........

So can we generalize it to (a+i)/(b+i), where i>=1

Choosing i is dependent on how much do you want to stress on denominator?

Any more comments on this

Title: Re: Comparison of fractions
Post by towr on Dec 1st, 2008, 12:30am

on 11/30/08 at 22:16:00, hoogle wrote:
What is the difference between a/(b+1) and (a+1)/b+2).........
Well, for one thing, n/(2n) stays 1/2. And a/b remains equal to 1-(b-a)/b.

Title: Re: Comparison of fractions
Post by Grimbal on Dec 1st, 2008, 12:33am

on 11/30/08 at 22:16:00, hoogle wrote:
What is the difference between a/(b+1) and (a+1)/b+2).........

It makes a difference especially when a=0.  0/1 is not as bad as 0/10.  With a/(b+1) it doesn't show a difference.  With (a+1)/(b+2), it does.

Title: Re: Comparison of fractions
Post by rmsgrey on Dec 1st, 2008, 10:21am
But is 15/20 any better or worse than 3/4 ? Both are 75%, and, while 3/4 could be as low as 5/8 (or 25/40), while 15/20 only goes down to 29/40, but 3/4 also goes up to 7/8 (35/40), while 15/20 only goes up to 31/40. It's only with 0/n or n/n that higher n is obviously better - the ranges are bounded by 0 and 1.



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board