Function Design: 5-Output Mapper Functions

Posted
Comments None

The series of 5-output mapper functions explores the same principles of the 4-output mappers, with the difference that we are now defining 5 intervals instead of just 4. And what's interesting is how well these functions scale up (97% hits for Map5A, 98% for Map5B, 99% for Map5C against 96% for the argmax), behaving very similarly to their counterparts of 4 outputs. Even with just 2 arguments we can create efficient 5-output mapper functions that show a performance comparable to the argmax function of 4 arguments (it would have been interesting to see how they compare to the argmin/argmax functions of 5 arguments, but it will have to wait for the powers that be at Gepsoft to increase max arity to 5 in GeneXproTools)!

And like we saw for the Map4A function described in the previous post, the value for the slack was also critical for the Map5A function, in this case with 15 as the best value (the reason for 15 is that I needed a value that divided neatly by 3; I also tried the values 1.5, 30, 150, and 1500).

As usual, I'm including the C++ code for all three 5-output mapper functions for you to take a look:

    // Map5A(x0,x1): 5-Output Mapper Function
    const double SLACK = 15.0;
    double output = 0.0;
    if (x[1] < (x[0] - SLACK))
        output = 0.0;
    else if (x[1] >= (x[0] - SLACK) && x[1] < (x[0] - SLACK/3.0))
        output = 1.0;
    else if (x[1] >= (x[0] - SLACK/3.0) && x[1] < (x[0] + SLACK/3.0))
        output = 2.0;
    else if (x[1] >= (x[0] + SLACK/3.0) && x[1] < (x[0] + SLACK))
        output = 3.0;
    else if (x[1] >= (x[0] + SLACK))
        output = 4.0;
    return output;

 

    // Map5B(x0,x1,x2): 5-Output Mapper Function
    // evaluate min(x,y), max(x,y), midpoint1 and midpoint2
    double min = x[0];
    double max = x[1];
    if (min > x[1])
    {
        min = x[1];
        max = x[0];
    }
    double intervalLength = (max - min)/3.0;
    double midpoint1 = min + intervalLength;
    double midpoint2 = min + 2.0*intervalLength;

    double output = 0.0;
    if (x[2] < min)
        output = 0.0;
    else if (x[2] >= min && x[2] < midpoint1)
        output = 1.0;
    else if (x[2] >= midpoint1 && x[2] < midpoint2)
        output = 2.0;
    else if (x[2] >= midpoint2 && x[2] < max)
        output = 3.0;
    else if (x[2] >= max)
        output = 4.0;
    return output;

 

    // Map5C(x0,x1,x2,x3): 5-Output Mapper Function
    // evaluate min(x,y,z), max(x,y,z), midleValue(x,y,z), midrange1, midrange2
    //
    // evaluate min(x,y,z)
    double min = x[0];
    int argmin = 0;
    if (min > x[1])
    {
        min = x[1];
        argmin = 1;
    }
    if (min > x[2])
    {
        min = x[2];
        argmin = 2;
    }
    // evaluate max(x,y,z)
    double max = x[0];
    int argmax = 0;
    if (max < x[1])
    {
        max = x[1];
        argmax = 1;
    }
    if (max < x[2])
    {
        max = x[2];
        argmax = 2;
    }
    // evaluate midleValue(x,y,z)
    double midleValue = x[2];
    if (0 != argmin && 0 != argmax)
        midleValue = x[0];
    if (1 != argmin && 1 != argmax)
        midleValue = x[1];
    // evaluate midrange1 and midrange2
    double midrange1 = (min + midleValue)/2.0;
    double midrange2 = (midleValue + max)/2.0;

    double output = 0.0;
    if (x[3] < min)
        output = 0.0;
    else if (x[3] >= min && x[3] < midrange1)
        output = 1.0;
    else if (x[3] >= midrange1 && x[3] < midrange2)
        output = 2.0;
    else if (x[3] >= midrange2 && x[3] < max)
        output = 3.0;
    else if (x[3] >= max)
        output = 4.0;
    return output;

In the next post we'll go a step further and describe the 6-output mapper functions of 2, 3, and 4 arguments.

Author

Comments

There are currently no comments on this article.

Comment

your_ip_is_blacklisted_by sbl.spamhaus.org

← Older Newer →