Skip to content

rolling product and numerical stability #7349

@jangorecki

Description

@jangorecki

rolling product should be more numerically stable
it should also handle 0 properly, now single pass algo does not handle it as it should

frollprod(c(2,2,0,2,2), 2)
#[1]  NA   4   0   0 NaN
frollprod(c(2,2,0,2,2), 2, algo="exact")
#[1] NA  4  0  0  4

edit:
While NaN above is an issue that have to be surely fix, the numerical stability is the issue that only affects adaptive rolling product (and therefore also partial=T) - it is due to implementation via cumprod.
Despite many attempts I have not been able to create a test case that could show the need for improving numerical stability for non-adaptive rolling product.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions