8000 BUG: special: Loss of precision in `logsumexp` · Issue #18295 · scipy/scipy · GitHub
[go: up one dir, main page]

Skip to content
BUG: special: Loss of precision in logsumexp #18295
@WarrenWeckesser

Description

@WarrenWeckesser

Describe your issue.

logsumexp loses precision in cases where it shouldn't, and in extreme cases it can return 0 when it should return a nonzero float.

Reproducing Code Example

In [2]: from scipy.special import logsumexp

In [3]: logsumexp([0, -40.0])
Out[3]: 0.0

In [4]: np.logaddexp(0, -40)  # This is the expected result of `logsumexp([0, -40.0])`.
Out[4]: 4.248354255291589e-18

SciPy/NumPy/Python version and system information

{
  "Compilers": {
    "c": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "11.3.0",
      "commands": "cc"
    },
    "cython": {
      "name": "cython",
      "linker": "cython",
      "version": "0.29.33",
      "commands": "cython"
    },
    "c++": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "11.3.0",
      "commands": "c++"
    },
    "fortran": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "11.3.0",
      "commands": "gfortran"
    },
    "pythran": {
      "version": "0.12.1",
      "include directory": "../../../../../py3.10.8/lib/python3.10/site-packages/pythran"
    }
  },
  "Machine Information": {
    "host": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "build": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "cross-compiled": false
  },
  "Build Dependencies": {
    "blas": {
      "name": "openblas",
      "found": true,
      "version": "0.3.20",
      "detection method": "pkgconfig",
      "include directory": "/usr/include/x86_64-linux-gnu/openblas-pthread/",
      "lib directory": "/usr/lib/x86_64-linux-gnu/openblas-pthread/",
      "openblas configuration": "USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 NO_CBLAS= NO_LAPACK= NO_LAPACKE=1 NO_AFFINITY=1 USE_OPENMP=0 generic MAX_THREADS=64",
      "pc file directory": "/usr/lib/x86_64-linux-gnu/pkgconfig"
    },
    "lapack": {
      "name": "openblas",
      "found": true,
      "version": "0.3.20",
      "detection method": "pkgconfig",
      "include directory": "/usr/include/x86_64-linux-gnu/openblas-pthread/",
      "lib directory": "/usr/lib/x86_64-linux-gnu/openblas-pthread/",
      "openblas configuration": "USE_64BITINT= DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 NO_CBLAS= NO_LAPACK= NO_LAPACKE=1 NO_AFFINITY=1 USE_OPENMP=0 generic MAX_THREADS=64",
      "pc file directory": "/usr/lib/x86_64-linux-gnu/pkgconfig"
    }
  },
  "Python Information": {
    "path": "/home/warren/py3.10.8/bin/python3",
    "version": "3.10"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.special

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0