MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Comparing Numbers - improving on log relative error

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27279] Comparing Numbers - improving on log relative error
  • From: "mvyver" <mvdv at bigfoot.com>
  • Date: Sun, 18 Feb 2001 02:52:13 -0500 (EST)
  • Organization: The University of Western Australia
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
This may be trivial... the idea is to take two numbers, or lists of numbers,
sumbit them to a function that returns a set of integers indicating the
numer of digits in agreement.  An eaxample should be clearer:

c = {-0.01683787816107418, 0.22080842442483295, 1310.3262295713917};
est = {{-0.01821756936118390, 0.2208605273841613, 1310.3353890004764},
      {0.017177028591333965, 0.22112030617117995, 1310.3270577680291},
      {-0.01715869524044578, 0.22093374833870505, 1310.3266833564685},
      {-0.016406423628831955, 0.2209052735237087, 1310.3260455795904}};

Comparing c to each of the lists in est should return something like - this
is by hand so there may be an error :)

result={{1, 3, 5}, {0, 2, 6}, {1, 3, 7}, {1, 3, 7}}

one approach is the log relative error:

LRE = -Log[10, Abs[(# - c)]/Abs[c]] & /@ est

which is off in some cases:

lreresult={{1.08651, 3.62715, 5.15551}, {-0.305382, 2.85003, 6.19925},
             {1.72003, 3.24598, 6.46053}, {1.59135, 3.35792, 6.85258}}

I tried applying RealDigits to each of the numbers, but then hit a snag in
counting the matching elements accurately.  If it make things easier the
sign checking I can do in a seperate step.

A more elaborate approach would indicate the bias in est relative to c, but
expect this may be quite tricky, eg. the result would then be:

result={{-1, 3, 5}, {-1, 2, 6}, {-1, 3, 7}, {1, 3, -7}}

Any suggestions/help appreciated.

Mark Van De Vyver

Dept Acc & Finance
University of Western Australia
Perth





  • Prev by Date: Re: Problem: a matrix and a box...
  • Next by Date: Re: Arrows on axes?
  • Previous by thread: Inverting yaxis in DensityPlot
  • Next by thread: simple Problem: D[ ]