Created
October 27, 2020 10:38
-
-
Save athas/28843a088ce60c6ca7bcf6a3c8f95a26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Summarises an n-element input in k bins, with each of the k bins | |
-- containing the maximum of the input in that span. | |
let main [n] (k: i64) (samples: [n]i32) = | |
let bin_size = f32.i64 n / f32.i64 k | |
let index i = i64.f32 (f32.i64 i / bin_size) | |
in reduce_by_index (replicate k 0) i32.max i32.highest | |
(map index (iota n)) samples |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment