Skip to content
New issue

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

Add geometric mean primitive #65

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

sternj
Copy link

@sternj sternj commented Aug 18, 2023

I'd like to add a geometric mean primitive to Insect and this seems like the first step! I've never seen Purescript before now so this is probably going to be quite broken.

@sternj
Copy link
Author

sternj commented Aug 19, 2023

So I've realized that I just... can't do division? please advise

@sternj
Copy link
Author

sternj commented Aug 19, 2023

Okay, so the code that I have is

geomean  NonEmptyList Quantity  Result
geomean xs = (_ `pow` ( one / n)) <$> foldM (⊗) (head xs) (tail xs)
  where
    n = Decimal.fromInt (length xs)

and the error at hand is

at src/Data/Quantity/Math.purs:183:45 - 183:48 (line 183, column 45 - line 183, column 48)

  Could not match type
            
    Quantity
            
  with type
               
    t2 Quantity
               

while checking that type Quantity -> Quantity -> Quantity
  is at least as general as type t0 -> t1 -> t2 t0
while checking that expression qMultiply
  has type t0 -> t1 -> t2 t0
in value declaration geomean

where t2 is an unknown type
      t1 is an unknown type
      t0 is an unknown type

@sharkdp
Copy link
Owner

sharkdp commented Oct 12, 2023

Thank you very much for creating this — and sorry for not getting back to you earlier. I have been working on a rewrite of Insect over the past year. I will likely not make further updates to Insect. If you are still interested in this feature, maybe you could add it to Numbat instead? (https://github.com/sharkdp/numbat)

There are three places to look (following the example of mean):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants