Guest User

Untitled

a guest
May 21st, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. (defn quantile-r8 [p d]
  2. (let [d (sort d)
  3. N (count d)
  4. h (+ (* (+ N (/ 1.0 3.0)) p) (/ 1.0 3.0))
  5. hfloor (Math/floor h)]
  6. (cond (< p (/ (/ 2.0 3.0) (+ N (/ 1.0 3.0)))) (first d)
  7. (>= p (/ (- N (/ 1.0 3.0)) (+ N (/ 1.0 3.0)))) (last d)
  8. :else (+ (nth d (- hfloor 1)) (* (- h hfloor) (- (nth d hfloor) (nth d (- hfloor 1)))))))
  9. )
Add Comment
Please, Sign In to add comment