Fuzzy comparison
- From: "Abstract Dissonance" <Abstract.Dissonance@xxxxxxxxxxx>
- Date: Thu, 6 Jul 2006 00:11:24 -0500
I'm trying to come up with a simple function that will allow me to compare
two real numbers in a "fuzzy" way. That is, I don't if a < b or b < a as
long as they are within some tolerance but I also want the function to "act"
like the normal comparison in most respects(i.e., g(x) = x).
Actually, for my purposes I want a function f(x) to have the properties for
two real numbers a and b,
if |b - a| < e then 0 <= f(b - a)
if a <(>) b then f(a-b) <=(>=) f(b-a)
f'(x) >= 0 for all x
f(x) ~= x for large x.
I'd also like to have f'(0) = 0 or ~= 0.
What I have done was to look at "gaussian" like functions such as
a*exp(-b*x^2) and rotate them Pi/4 cc to get an "appropriate" function.
Unfortunately this leaves me with a parametric function when I'd like a
single valued function. (although there is a theoretical reduction of the
parametric function, it is not very practical for the given function).
There are a whole host of functions that have these properties(when rotated)
such as a - abs(x) for -a < x < a else 0, a/(b + x^2), etc...
All the ones I have looked at end up with complicated expressions for
controlling the "tolerance" and/or "height".
What I'd really like is a simple function that has the properties above with
parameters to control the tolerance, rate of convergence to x(for both
"sides"), and "flatness" around 0.
Heres what I mean,
e.g., take f(x) = h - abs(x)
/|\
/ | \
/ | \
/ | \
--------+--------
|
|
|
|
rotate it Pi/4 cc to get
x' = sqrt(2)/2*(x + f(x))
y' = sqrt(2)/2*(x - f(x))
which has the graph
| /
___|___/
| |
| |
----|---+--------
| |
| |
/ |
/ |
The tolerance is the approximate "horizontal" width of the function at the
"height". I need to be able to easily control its width independently to set
some sort of "metric" for a = b. The height just makes b - a return a
positive value if b - a is within some tolerance... this is for my
application. It should also be independently controlled(i.e., changing it
doesn't screw up the other controls to much). The rate of "convergence" is
how fast the function "returns" to the normal comparison when |b - a| is
larger than the tolerance. In the above case, if |x| < e and x < 0 then the
function has "infinite" convergence to the graph y = x. (which is not what I
want as I really want it quite smooth). In the case that x > 0 it is "dead
on" with y = x.
In effect I suppose one could define a piecewise smooth function for each of
the parts and it should work and be quite simple but I was hoping for a
single function to do the job.
Hopefully I'm making some sense. Its kinda hard for me to explain exactly
what I want. Basically I need to compare several pairs of real numbers at
once. I am trying to create a function that takes these pairs(actually the
difference) and returns a real number that represents how "close" they are
but if they are approximately equal then it returns a "measure" of this
equality. Then I will apply this function to each pair and sum up the
total(but a weighted sum). Then I will get a single real number expressing
approximate condition of all the pairs of real numbers equaling each other.
i.e.
say I have
{1, 2}
{3, 4}
{9, -3}
then I take the differences
2 - 1 = 1
4 - 3 = 1
-3 - 9 = -12
Apply the function(but parameters are adjusted for each pair since they
represent different quantities) to the differences, maybe one gets
0.2
0.8
0.1
then take a weight sum, lets suppose its 4. Now I am actually using it to
compare two lists to see which one is "better". If I have another list and
have a value of 3 then I will take this list as being better. If I have
choosen the parameters and weights properly then it should be a good measure
of which list is better... although in reality it might not choose the best
list it should choose a "good" list.
The whole reason for this is because if I just do a direct comparison I
might have the two lists,
1, 3
and
5, 2
To compare the lists we see which one is "larger" than the other
1 < 5 but 3 > 2. So the lists are at "odds".
But because the points represent different quantities there isn't a way to
get an idea of which one is better. Now if one had the list
1, 5 and 5, 6
then since both cases the second list is larger we can say the second list
is better. It also may turn out that the first quantity is more important
then the second one too.
Hopefully that didn't result in more confusion ;)
Thanks,
Jon
.
- Follow-Ups:
- Re: Fuzzy comparison
- From: William Elliot
- Re: Fuzzy comparison
- From: Han de Bruijn
- Re: Fuzzy comparison
- Prev by Date: Re: Mathematical existentiality and triviality.
- Next by Date: Re: They wouldn't believe otherwise
- Previous by thread: factorization an NP problem (don't see it)
- Next by thread: Re: Fuzzy comparison
- Index(es):
Relevant Pages
|