You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "Jake Mannix (JIRA)" <ji...@apache.org> on 2010/01/27 08:00:37 UTC

[jira] Created: (MAHOUT-267) Vector.norm(x) uses incorrect formula for both x == POSITIVE_INFINITY and x == 1

Vector.norm(x) uses incorrect formula for both x == POSITIVE_INFINITY and x == 1
--------------------------------------------------------------------------------

                 Key: MAHOUT-267
                 URL: https://issues.apache.org/jira/browse/MAHOUT-267
             Project: Mahout
          Issue Type: Bug
          Components: Math
    Affects Versions: 0.1, 0.2
         Environment: all
            Reporter: Jake Mannix
            Priority: Minor
             Fix For: 0.3


Ugh.  This is the second time I've had to fix the definition of an L_p norm in an Apache project.


{code}  
@Override
  public double norm(double power)  {
    if (power < 0.0) {
      throw new IllegalArgumentException("Power must be >= 0");
    }
    // we can special case certain powers
    if (Double.isInfinite(power)) {
      return maxValue();
    } else if (power == 2.0) {
      return Math.sqrt(dot(this));
    } else if (power == 1.0) {
      return zSum();
    } else if (power == 0.0) {
...
}
{code}

Spot the errors?  Hint: both maxValue() and zSum() can return negative values, which is a no-no for norms unless we're going to do Relativity and have Lorentzian metrics allowed in Mahout:
  * maxValue() returns the maximum (meaning: closest to POSITIVE_INFINITY) value, which means large negative numbers aren't noticed and factored in.
  * zSum() adds all the values - not their absolute values.

I'll check in a fix with some of my other code, but I wanted this tracked, as apparently the norm(double) method is so often used that this was never noticed in unit tests OR by users (the fact that nobody's ever noticed this makes me log this as a "minor" bug).  :(

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (MAHOUT-267) Vector.norm(x) uses incorrect formula for both x == POSITIVE_INFINITY and x == 1

Posted by "Jake Mannix (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-267?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jake Mannix reassigned MAHOUT-267:
----------------------------------

    Assignee: Jake Mannix

> Vector.norm(x) uses incorrect formula for both x == POSITIVE_INFINITY and x == 1
> --------------------------------------------------------------------------------
>
>                 Key: MAHOUT-267
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-267
>             Project: Mahout
>          Issue Type: Bug
>          Components: Math
>    Affects Versions: 0.1, 0.2
>         Environment: all
>            Reporter: Jake Mannix
>            Assignee: Jake Mannix
>            Priority: Minor
>             Fix For: 0.3
>
>
> Ugh.  This is the second time I've had to fix the definition of an L_p norm in an Apache project.
> {code}  
> @Override
>   public double norm(double power)  {
>     if (power < 0.0) {
>       throw new IllegalArgumentException("Power must be >= 0");
>     }
>     // we can special case certain powers
>     if (Double.isInfinite(power)) {
>       return maxValue();
>     } else if (power == 2.0) {
>       return Math.sqrt(dot(this));
>     } else if (power == 1.0) {
>       return zSum();
>     } else if (power == 0.0) {
> ...
> }
> {code}
> Spot the errors?  Hint: both maxValue() and zSum() can return negative values, which is a no-no for norms unless we're going to do Relativity and have Lorentzian metrics allowed in Mahout:
>   * maxValue() returns the maximum (meaning: closest to POSITIVE_INFINITY) value, which means large negative numbers aren't noticed and factored in.
>   * zSum() adds all the values - not their absolute values.
> I'll check in a fix with some of my other code, but I wanted this tracked, as apparently the norm(double) method is so often used that this was never noticed in unit tests OR by users (the fact that nobody's ever noticed this makes me log this as a "minor" bug).  :(

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MAHOUT-267) Vector.norm(x) uses incorrect formula for both x == POSITIVE_INFINITY and x == 1

Posted by "Jake Mannix (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MAHOUT-267?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jake Mannix resolved MAHOUT-267.
--------------------------------

    Resolution: Fixed

fixed in r903965

> Vector.norm(x) uses incorrect formula for both x == POSITIVE_INFINITY and x == 1
> --------------------------------------------------------------------------------
>
>                 Key: MAHOUT-267
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-267
>             Project: Mahout
>          Issue Type: Bug
>          Components: Math
>    Affects Versions: 0.1, 0.2
>         Environment: all
>            Reporter: NOT_A_USER
>            Assignee: Jake Mannix
>            Priority: Minor
>             Fix For: 0.3
>
>
> Ugh.  This is the second time I've had to fix the definition of an L_p norm in an Apache project.
> {code}  
> @Override
>   public double norm(double power)  {
>     if (power < 0.0) {
>       throw new IllegalArgumentException("Power must be >= 0");
>     }
>     // we can special case certain powers
>     if (Double.isInfinite(power)) {
>       return maxValue();
>     } else if (power == 2.0) {
>       return Math.sqrt(dot(this));
>     } else if (power == 1.0) {
>       return zSum();
>     } else if (power == 0.0) {
> ...
> }
> {code}
> Spot the errors?  Hint: both maxValue() and zSum() can return negative values, which is a no-no for norms unless we're going to do Relativity and have Lorentzian metrics allowed in Mahout:
>   * maxValue() returns the maximum (meaning: closest to POSITIVE_INFINITY) value, which means large negative numbers aren't noticed and factored in.
>   * zSum() adds all the values - not their absolute values.
> I'll check in a fix with some of my other code, but I wanted this tracked, as apparently the norm(double) method is so often used that this was never noticed in unit tests OR by users (the fact that nobody's ever noticed this makes me log this as a "minor" bug).  :(

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.