Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun percentage-lineariser (x)
- "Converts a percentage form into a more linear format. For example:
- 4/5 -> 80% -> -0.25
- 3/2 -> 150% -> 0.5
- 2/1 -> 200% -> 1.0
- 1/2 -> 50% -> -1.0
- This format is easier to work with difference-judging strategies such as
- EXPONENTIAL-MOVING-AVERAGE-STRATEGY. This function is undefined for negative
- and zero values."
- (assert (plusp x) (x)
- "Percentage must be positive")
- (cond
- ((> x 1) (1- x))
- ((= x 1) 0)
- ((< x 1) (- 1 (/ x)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement