You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is one way to resolve #146. All examples here will use mean but readily generalizes to all fold based estimators and with some problems to quantiles and like which will require building intermediate vector.
Current implementation of mean have following signature: mean :: (G.Vector v Double) => v Double -> Double and as such could only work with vectors. Which is very inconvenient. Proposal is to take Getting for data structure as parameter
meanOf :: Getting (Endo (Endo MeanKBN)) s Double -> s -> Double
This surprisingly powerful API. Here are examples
meanOf each will compute mean of instance of Each type class that it will work for vector, lists, Maps and lot of other data structures
meanof folded will work for any Foldable
meanOf (each . each) will compute mean of nested containers
meanOf (each . filtered (>0) . to log) will compute mean of logarithm of every positive number.
So this is very powerful and generic API. Preliminary benchmarks indicate that it's possible to get performance identical to current implementation. Only downside it requires use of lens but I think gained power worth it.
The text was updated successfully, but these errors were encountered:
This is one way to resolve #146. All examples here will use
mean
but readily generalizes to all fold based estimators and with some problems to quantiles and like which will require building intermediate vector.Current implementation of mean have following signature:
mean :: (G.Vector v Double) => v Double -> Double
and as such could only work with vectors. Which is very inconvenient. Proposal is to takeGetting
for data structure as parameterThis surprisingly powerful API. Here are examples
meanOf each
will compute mean of instance ofEach
type class that it will work for vector, lists, Maps and lot of other data structuresmeanof folded
will work for any FoldablemeanOf (each . each)
will compute mean of nested containersmeanOf (each . filtered (>0) . to log)
will compute mean of logarithm of every positive number.So this is very powerful and generic API. Preliminary benchmarks indicate that it's possible to get performance identical to current implementation. Only downside it requires use of lens but I think gained power worth it.
The text was updated successfully, but these errors were encountered: