[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Another Gaussian hack ...
- To: info-mcl-digest%cambridge.apple.com@RIVERSIDE.SCRC.SYMBOLICS.COM
- Subject: Another Gaussian hack ...
- From: Martin Mallinson <Martin@VEGA.cmt.dialnet.symbolics.com>
- Date: Sun, 1 Aug 1993 19:58-0400
- Character-type-mappings: (1 0 (NIL 0) (NIL :BOLD NIL) "CPTFONTCB")
- Fonts: CPTFONT, CPTFONTCB
Here is a quick way to make a close-to-gaussian generator:
(defun random-gauss1 0(&optional correlation-coeff (mean 0) (sd 1))
(let ((previous-correlated-gauss 0))
(if correlation-coeff
#'(lambda ()
(setq previous-correlated-gauss
(+ (* correlation-coeff previous-correlated-gauss)
(* (sqrt (- 1 (* correlation-coeff correlation-coeff)))
(+ mean (* sd (- (loop repeat 12
sum (* (random 10000000)
#.(/ 10000000.0)))
6)))))))
#'(lambda ()
(+ mean (* sd (- (loop repeat 12
sum (* (random 10000000)
#.(/ 10000000.0)))
6)))))))
Its good enough for noise analysis in simulations and similar stuff.
Call the function it returns any time you need another random point -
note that you can specify a correlation coefficient - useful for so called
"band-limited" gaussian noise simulations in electronic circuits.
--------------------------------------------------------------------------------
Martin Mallinson martin@cmt.dialnet.symbolics.com
Crimble Micro Test Inc.
5 Tomahawk Drive Phone: 508 667 9405
Billerica MA 01821 Fax: 508 667 0192
--------------------------------------------------------------------------------