+ Reply to Thread
Results 1 to 4 of 4

A math/algorithm puzzle!

  1. #1
    rci
    Guest

    A math/algorithm puzzle!

    Hi all...

    Using VB in a appplication that needs to solve a bit of a math/algorithm
    problem, and thought the good people here would have interesting ideas on
    how to solve it...

    Without going into too much detail, basically the code must find/suggest the
    best pairs of numbers from a single list, and be able to exclude "outliers".

    Pairing would be the best pairings possible by closest value.

    Example:

    data:
    25
    22
    31
    24
    25
    22
    28
    18
    23

    I would want to be able to adjust the sensitivity of the code to start to
    trim outliers from the data, like "18" would seem to be the biggest
    troublemaker in creating similar pairs... resulting in a list like this:


    31 28
    25 25
    24 23
    22 22
    excluded: 18


    The largest delta is three in this case... but you can see how the
    logic/sorting might become complex, especially when the list of data becomes
    much larger.

    Thoughts?

    Thx,

    SMS

  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Why not just have VBA sort your data and then compare the difference between teh first and second numbers with the difference between the last and second to last numbers in your list? This would identify your greatest outlier and it could be handled accordingly.

  3. #3
    Alex
    Guest

    RE: A math/algorithm puzzle!

    rci

    At first glance...

    Why not work out the mean and standard deviation of your numbers and say...

    a) exclude any number greater or less than 3 s.d.'s (as outliers)
    b) try pairing numbers by their distance above and below the mean e.g check
    for numbers within +/- 0.5 sd of mean and pair them, then look at numbers +/-
    0.51 to 1sd from mean, then 1.01 to 1.5sd etc.

    Just a preliminary thought...

    Alex

    "rci" wrote:

    > Hi all...
    >
    > Using VB in a appplication that needs to solve a bit of a math/algorithm
    > problem, and thought the good people here would have interesting ideas on
    > how to solve it...
    >
    > Without going into too much detail, basically the code must find/suggest the
    > best pairs of numbers from a single list, and be able to exclude "outliers".
    >
    > Pairing would be the best pairings possible by closest value.
    >
    > Example:
    >
    > data:
    > 25
    > 22
    > 31
    > 24
    > 25
    > 22
    > 28
    > 18
    > 23
    >
    > I would want to be able to adjust the sensitivity of the code to start to
    > trim outliers from the data, like "18" would seem to be the biggest
    > troublemaker in creating similar pairs... resulting in a list like this:
    >
    >
    > 31 28
    > 25 25
    > 24 23
    > 22 22
    > excluded: 18
    >
    >
    > The largest delta is three in this case... but you can see how the
    > logic/sorting might become complex, especially when the list of data becomes
    > much larger.
    >
    > Thoughts?
    >
    > Thx,
    >
    > SMS
    >


  4. #4
    Gary's Student
    Guest

    RE: A math/algorithm puzzle!

    Another suggestion:

    FIrst sort the numbers. This will put close numbers next to each other.
    Then calculate the differences, for example A1 to A2, A2 to A3, etc. and
    select the smallest differences for the pairs. Outliers would have large
    differences from both their neighbors.
    --
    Gary's Student


    "Alex" wrote:

    > rci
    >
    > At first glance...
    >
    > Why not work out the mean and standard deviation of your numbers and say...
    >
    > a) exclude any number greater or less than 3 s.d.'s (as outliers)
    > b) try pairing numbers by their distance above and below the mean e.g check
    > for numbers within +/- 0.5 sd of mean and pair them, then look at numbers +/-
    > 0.51 to 1sd from mean, then 1.01 to 1.5sd etc.
    >
    > Just a preliminary thought...
    >
    > Alex
    >
    > "rci" wrote:
    >
    > > Hi all...
    > >
    > > Using VB in a appplication that needs to solve a bit of a math/algorithm
    > > problem, and thought the good people here would have interesting ideas on
    > > how to solve it...
    > >
    > > Without going into too much detail, basically the code must find/suggest the
    > > best pairs of numbers from a single list, and be able to exclude "outliers".
    > >
    > > Pairing would be the best pairings possible by closest value.
    > >
    > > Example:
    > >
    > > data:
    > > 25
    > > 22
    > > 31
    > > 24
    > > 25
    > > 22
    > > 28
    > > 18
    > > 23
    > >
    > > I would want to be able to adjust the sensitivity of the code to start to
    > > trim outliers from the data, like "18" would seem to be the biggest
    > > troublemaker in creating similar pairs... resulting in a list like this:
    > >
    > >
    > > 31 28
    > > 25 25
    > > 24 23
    > > 22 22
    > > excluded: 18
    > >
    > >
    > > The largest delta is three in this case... but you can see how the
    > > logic/sorting might become complex, especially when the list of data becomes
    > > much larger.
    > >
    > > Thoughts?
    > >
    > > Thx,
    > >
    > > SMS
    > >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1