Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
alexandria
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
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 gaussian-random when min or max is nil but not both.
parent
1f3ae3aa
Changes
1
Show whitespace changes
Inline
Side-by-side
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,7 +18,11 @@ 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
()
(
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
)
...
...
@@ -26,23 +30,23 @@ similarly if MAX is negative it should be close to zero."
when
(
<
w
1.0d0
)
do
(
let
((
v
(
sqrt
(
/
(
*
-2.0d0
(
log
w
))
w
))))
(
return
(
values
(
*
x1
v
)
(
*
x2
v
))))))
(
guard
(
x
min
ma
x
)
(
unless
(
<=
min
x
ma
x
)
(
guard
(
x
)
(
unless
(
valid
x
)
(
tagbody
:retry
(
multiple-value-bind
(
x1
x2
)
(
gauss
)
(
when
(
<=
min
x1
max
)
(
when
(
valid
x1
)
(
setf
x
x1
)
(
go
:done
))
(
when
(
<=
min
x2
max
)
(
when
(
valid
x2
)
(
setf
x
x2
)
(
go
:done
))
(
go
:retry
))
:done
))
x
))
(
multiple-value-bind
(
g1
g2
)
(
gauss
)
(
values
(
guard
g1
(
or
min
g1
)
(
or
max
g1
)
)
(
guard
g2
(
or
min
g2
)
(
or
max
g2
))))))
(
multiple-value-bind
(
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