;;;; srfi-27-paretos.scm ;;;; Kon Lovett, Dec '17 ;;;; Kon Lovett, Jun '17 ;;;; Kon Lovett, May '06 ; Chicken Generic Arithmetic! (could use fp routines) (module srfi-27-paretos (;export *make-random-paretos make-random-paretos) (import scheme chicken) (use (only type-errors error-argument-type) (only type-checks define-check+error-type check-procedure check-cardinal-integer check-real check-open-interval check-closed-interval) srfi-27 srfi-27-distributions-support srfi-27-gammas srfi-27-exponentials) ;;; Pareto distribution (define (*make-random-paretos alpha xmin randoms) (let ((gammas (*make-random-gammas alpha (*reciprocal xmin) randoms))) (*make-random-exponentials 1.0 (lambda () (*reciprocal (+ xmin (gammas)))))) ) (define (make-random-paretos #!key (alpha 1.0) (xmin 1.0) (randoms (random-real/current))) (check-positive-real 'make-random-paretos alpha 'alpha) (check-positive-real 'make-random-paretos xmin 'xmin) (check-procedure 'make-random-paretos randoms 'randoms) (values (*make-random-paretos alpha xmin randoms) (lambda () (values alpha xmin randoms))) ) ) ;module srfi-27-paretos