;;;; srfi.27.erlangs.scm ;;;; Kon Lovett, Dec '17 ;;;; Kon Lovett, Jun '17 ;;;; Kon Lovett, May '06 ; Chicken Generic Arithmetic! (would use fp routines, except for the "real" constraint) (module srfi.27.erlangs (;export *make-random-erlangs make-random-erlangs) (import scheme (chicken base) (chicken type) (only (type-checks-numbers scheme) check-real) (only type-checks-structured check-procedure) (srfi 27) srfi-27-distributions-support (srfi 27 gammas)) ;;; (include-relative "srfi-27-common-types") (: *make-random-erlangs (number number random-real-function -> number-function)) (: make-random-erlangs (#!rest -> number-function procedure)) ;;; Erlang distribution (define (*make-random-erlangs alpha theta randoms) (*make-random-gammas (exact->inexact alpha) (exact->inexact theta) randoms) ) (define (make-random-erlangs #!key (alpha 1) (theta 1) (randoms (current-random-real))) (check-positive-real 'make-random-erlangs alpha 'alpha) (check-positive-real 'make-random-erlangs theta 'theta) (check-procedure 'make-random-erlangs randoms 'randoms) (values (*make-random-erlangs alpha theta randoms) (lambda () (values alpha theta randoms))) ) ) ;module srfi.27.erlangs