Changeset 2444 in project


Ignore:
Timestamp:
11/15/06 17:47:57 (15 years ago)
Author:
Kon Lovett
Message:

Added levy dist.

Location:
srfi-27
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • srfi-27/srfi-27-distributions.scm

    r1970 r2444  
    77        (declare
    88                (not usual-integrations
    9                         number?
     9                        number? real? integer? positive? zero? negative?
    1010                        = >= <= < >
    1111                        inexact->exact
     
    2828                        make-random-erlangs
    2929                        make-random-paretos
     30                        make-random-levys
    3031                        random-normal-vector!
    3132                        random-hollow-sphere!
     
    9192                        (error "not a proper vector" vec)])     )
    9293
    93 (define (vector*-scale! vec const)
     94(define-inline (vector*-scale! vec const)
    9495        (vector*-map! (lambda (i elm) (* elm const)) vec) )
    9596
    96 (define (vector*-sum-squares vec)
     97(define-inline (vector*-sum-squares vec)
    9798        (vector*-fold (lambda (i sum elm) (+ sum (* elm elm))) 0 vec) )
    9899
    99 ;;; Uniform random reals in (0 1)
     100;;; Uniform random integers in [low high]
    100101
    101102(define (make-uniform-random-integers #!optional (high #f) (low 0) (unit 1) (src (current-random-source-structure)))
     
    188189;; Knuth's "The Art of Computer Programming", Vol. II, 2nd ed.,
    189190;; Algorithm P of Section 3.4.1.C.
    190 ;;
     191
    191192(define (make-random-normals #!optional (mu 0.0) (sigma 1.0) (rand (make-uniform-random-reals)))
    192193        (unless (real? mu)
     
    216217
    217218;; s - smallest, m - most probable, l - largest
     219
    218220(define (make-random-triangles #!optional (s 0.0) (m 0.5) (l 1.0) (rand (make-uniform-random-reals)))
    219221        (unless (real? s)
     
    292294                (values
    293295                        (lambda ()
    294                                 (+ 1 (inexact->exact (floor (/ (log (- 1 (rand))) log-p)))))
     296                                (+ 1 (inexact->exact (floor (/ (log (- 1.0 (rand))) log-p)))))
    295297                        (lambda ()
    296298                                (values p rand)))) )
     
    329331;; "A Simple Method for Generating Gamma Variables", George Marsaglia & Wai Wan Tsang,
    330332;; ACM Transactions on Mathematical Software, Vol. 26, No. 3, September 2000, Pages 363Ð372.
    331 ;;
     333
    332334(define (make-random-gammas #!optional (alpha 1.0) (theta 1.0) (rand (make-uniform-random-reals)))
    333335        (unless (and (real? alpha) (positive? alpha))
     
    385387                (lambda () (values alpha xmin rand))) )
    386388
     389;;; LŽvys
     390
     391(define (make-random-levys #!optional (gamma 1.0) (delta 0.0) (rand (make-uniform-random-reals)))
     392        (unless (and (real? delta) (not (negative? delta)))
     393                (error 'make-random-levys "delta must be a non-negative real" delta))
     394        (unless (and (real? gamma) (positive? gamma))
     395                (error 'make-random-levys "gamma must be a positive real" gamma))
     396        (values
     397                (if (and (= 1.0 gamma) (= 0.0 delta))
     398                        (lambda ()
     399                                (let ([r (rand)])
     400                                        (/ 1.0 (* r r))))
     401                        (lambda ()
     402                                (let ([r (rand)])
     403                                        (+ delta (* gamma (/ 1.0 (* r r)))))))
     404                (lambda () (values gamma delta rand))) )
     405
    387406;;; Normal vectors
    388407
  • srfi-27/srfi-27-eggdoc.scm

    r1971 r2444  
    3838                (author (url "mailto:klovett@pacbell.net" "Kon Lovett"))
    3939                (history
     40                        (version "1.3" "Added Levy distribution")
    4041                        (version "1.2" "Added Pareto & Erlang distributions")
    4142                        (version "1.1" "Changed entropy source port close timeout handler")
     
    252253                                        (p "Pareto distributed random inexact reals."))
    253254
     255                                (procedure "(make-random-levys [GAMMA 1] [DELTA 0] [RAND])"
     256                                        (p "Levy distributed random inexact reals."))
     257
    254258                                (procedure "(random-normal-vector! VECTOR [MEAN 0] [STDDEV 1] [RAND])"
    255259                                        (p "Fills the " (tt "VECTOR") " with normal distributed real "
  • srfi-27/srfi-27.setup

    r1842 r2444  
    11(include "setup-header")
    22
    3 (install-dynld entropy-primitives "1.1" -O3 -d0 +easyffi +dollar)
    4 (install-dynld entropy "1.1")
     3(install-dynld entropy-primitives "1.3" -O3 -d0 +easyffi +dollar)
     4(install-dynld entropy "1.3")
    55
    6 (install-dynld srfi-27-structures "1.1")
     6(install-dynld srfi-27-structures "1.3")
    77
    8 (install-dynld srfi-27-large-numbers "1.1" -O3 -d0)
     8(install-dynld srfi-27-large-numbers "1.3" -O3 -d0)
    99
    10 (install-dynld mrg32k3a-primitives "1.1" -O3 -d0 +easyffi +dollar)
    11 (install-dynld mrg32k3a "1.1")
     10(install-dynld mrg32k3a-primitives "1.3" -O3 -d0 +easyffi +dollar)
     11(install-dynld mrg32k3a "1.3")
    1212
    13 (install-dynld mwc-primitives "1.1" -O3 -d0 +easyffi +dollar)
    14 (install-dynld mwc "1.1")
     13(install-dynld mwc-primitives "1.3" -O3 -d0 +easyffi +dollar)
     14(install-dynld mwc "1.3")
    1515
    16 (install-dynld srfi-27-parameters "1.1")
     16(install-dynld srfi-27-parameters "1.3")
    1717
    18 (install-dynld srfi-27-distributions "1.1")
     18(install-dynld srfi-27-distributions "1.3")
    1919
    20 (install-dynld+docu srfi-27 "1.1")
     20(install-dynld+docu srfi-27 "1.3")
Note: See TracChangeset for help on using the changeset viewer.