Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
alexandria
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Momchil Ivanov
alexandria
Commits
b8bd1033
Unverified
Commit
b8bd1033
authored
Feb 04, 2013
by
aarvid
Committed by
Attila Lendvai
Feb 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in gaussianrandom when min or max is nil but not both.
parent
1f3ae3aa
Changes
1
Hide whitespace changes
Inline
Sidebyside
Showing
1 changed file
with
29 additions
and
25 deletions
+29
25
numbers.lisp
numbers.lisp
+29
25
No files found.
numbers.lisp
View file @
b8bd1033
...
...
@@ 18,31 +18,35 @@ normal distribution around 0.0d0.
Sufficiently positive MIN or negative MAX will cause the algorithm used to
take a very long time. If MIN is positive it should be close to zero, and
similarly if MAX is negative it should be close to zero."
(
labels
((
gauss
()
(
loop
for
x1
=
(

(
random
2.0d0
)
1.0d0
)
for
x2
=
(

(
random
2.0d0
)
1.0d0
)
for
w
=
(
+
(
expt
x1
2
)
(
expt
x2
2
))
when
(
<
w
1.0d0
)
do
(
let
((
v
(
sqrt
(
/
(
*
2.0d0
(
log
w
))
w
))))
(
return
(
values
(
*
x1
v
)
(
*
x2
v
))))))
(
guard
(
x
min
max
)
(
unless
(
<=
min
x
max
)
(
tagbody
:retry
(
multiplevaluebind
(
x1
x2
)
(
gauss
)
(
when
(
<=
min
x1
max
)
(
setf
x
x1
)
(
go
:done
))
(
when
(
<=
min
x2
max
)
(
setf
x
x2
)
(
go
:done
))
(
go
:retry
))
:done
))
x
))
(
multiplevaluebind
(
g1
g2
)
(
gauss
)
(
values
(
guard
g1
(
or
min
g1
)
(
or
max
g1
))
(
guard
g2
(
or
min
g2
)
(
or
max
g2
))))))
(
macrolet
((
valid
(
x
)
`
(
<=
(
or
min
,
x
)
,
x
(
or
max
,
x
))
))
(
labels
((
gauss
()
(
loop
for
x1
=
(

(
random
2.0d0
)
1.0d0
)
for
x2
=
(

(
random
2.0d0
)
1.0d0
)
for
w
=
(
+
(
expt
x1
2
)
(
expt
x2
2
))
when
(
<
w
1.0d0
)
do
(
let
((
v
(
sqrt
(
/
(
*
2.0d0
(
log
w
))
w
))))
(
return
(
values
(
*
x1
v
)
(
*
x2
v
))))))
(
guard
(
x
)
(
unless
(
valid
x
)
(
tagbody
:retry
(
multiplevaluebind
(
x1
x2
)
(
gauss
)
(
when
(
valid
x1
)
(
setf
x
x1
)
(
go
:done
))
(
when
(
valid
x2
)
(
setf
x
x2
)
(
go
:done
))
(
go
:retry
))
:done
))
x
))
(
multiplevaluebind
(
g1
g2
)
(
gauss
)
(
values
(
guard
g1
)
(
guard
g2
))))))
(
declaim
(
inline
iota
))
(
defun
iota
(
n
&key
(
start
0
)
(
step
1
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment