We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
quite similar to Sum... Prod could track the overall product.
Sum
Prod
I haven't find such a statistics.
Implementing it could be interesting.
Kind regards
PS: here is an implementation idea inspired by Sum implementation
""" Prod(T::Type = Float64) Track the overall prod. """ mutable struct Prod{T} <: OnlineStat{Number} prod::T n::Int end Prod(T::Type = Float64) = Prod(one(T), 0) Base.prod(o::Prod) = o.prod OnlineStatsBase._fit!(o::Prod{T}, x::Real) where {T<:AbstractFloat} = (o.prod *= convert(T, x); o.n += 1) OnlineStatsBase._fit!(o::Prod{T}, x::Real) where {T<:Integer} = (o.prod *= round(T, x); o.n += 1) OnlineStatsBase._fit!(o::Prod{T}, x::Real, n) where {T<:AbstractFloat} = (o.prod *= convert(T, x * n); o.n += n) OnlineStatsBase._fit!(o::Prod{T}, x::Real, n) where {T<:Integer} = (o.prod *= round(T, x * n); o.n += n) OnlineStatsBase._merge!(o::T, o2::T) where {T <: Prod} = (o.prod *= o2.prod; o.n += o2.n; o)
PS2: here is my use cases https://github.com/femtotrader/OnlinePortfolioAnalytics.jl/blob/9ab6010cfb604c1484cd338609c47b643a001750/src/mean_return.jl#L40 https://github.com/femtotrader/OnlinePortfolioAnalytics.jl/blob/9ab6010cfb604c1484cd338609c47b643a001750/src/drawdowns.jl#L14 https://github.com/femtotrader/OnlinePortfolioAnalytics.jl/blob/9ab6010cfb604c1484cd338609c47b643a001750/src/cumulative_return.jl#L12
The text was updated successfully, but these errors were encountered:
I'm hesitant to add this since there would need to be a lot of special care to handle overflow/underflow.
Sorry, something went wrong.
No branches or pull requests
Hello,
quite similar to
Sum
...Prod
could track the overall product.I haven't find such a statistics.
Implementing it could be interesting.
Kind regards
PS: here is an implementation idea inspired by Sum implementation
PS2: here is my use cases
https://github.com/femtotrader/OnlinePortfolioAnalytics.jl/blob/9ab6010cfb604c1484cd338609c47b643a001750/src/mean_return.jl#L40
https://github.com/femtotrader/OnlinePortfolioAnalytics.jl/blob/9ab6010cfb604c1484cd338609c47b643a001750/src/drawdowns.jl#L14
https://github.com/femtotrader/OnlinePortfolioAnalytics.jl/blob/9ab6010cfb604c1484cd338609c47b643a001750/src/cumulative_return.jl#L12
The text was updated successfully, but these errors were encountered: