Skip to content

[bug] torch.polygamma inconsistent with scipy.special.polygamma for n >= 1 #55357

@kshitij12345

Description

@kshitij12345

n = 1

>>> t = torch.tensor([-1.])
>>> torch.polygamma(1, t)
tensor([1.2914e+15])
>>> scipy.special.polygamma(1, t.numpy())
array([inf], dtype=float32)

>>> t = torch.tensor([-501.])
>>> torch.polygamma(1, t)
tensor([2.0831e+09])
>>> scipy.special.polygamma(1, t.numpy())
array([inf], dtype=float32)

>>> t = torch.tensor([-float('inf')])
>>> torch.polygamma(1, t)
tensor([nan])
>>> scipy.special.polygamma(1, t.numpy())
array([inf], dtype=float32)
>>> 

n > 1

>>> t = torch.tensor([float('inf')])
>>> torch.polygamma(2, t)
tensor([nan])
>>> scipy.special.polygamma(2, t.numpy())
array([-0.], dtype=float32)
>>> torch.polygamma(3, t)
tensor([nan])
>>> scipy.special.polygamma(3, t.numpy())
array([0.], dtype=float32)
>>> torch.polygamma(4, t)
tensor([nan])
>>> scipy.special.polygamma(4, t.numpy())
array([-0.], dtype=float32)

cc @mruberry

Metadata

Metadata

Assignees

Labels

module: correctness (silent)issue that returns an incorrect result silentlymodule: specialFunctions with no exact solutions, analogous to those in scipy.specialtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions