Re: forcing representation of denominator 1?
- From: verec <verec@xxxxxxx>
- Date: Sun, 7 May 2006 00:28:18 +0100
On 2006-05-06 22:32:06 +0100, Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> said:
(denominator 5) --> 1
When you use the function pay-win-to-risk, you're working within your
"representation", and you're getting the correct results:
(values (numerator (pay-win-to-risk-reward 5/6))
(denominator (pay-win-to-risk-reward 5/6)))
--> 5 ;
1
At the last step, you'll need to use force-rational-output (but I'd
call it PRINT-ODDS instead).
The REPL printer is a debugger tool, not an application user interface!
I see that :-) I was just hoping that there existed some super
secret type that only CLHS anthropologists :) could know of that
would be some kind of
rational-that-prints-its-denominator-no-matter-what
Failing that, I was expecting a *print-xyz* var to set to this or that
so as to force the printer to output denominator values of 1 ...
Tough luck :-(
I've got some questions for you. What do the following forms mean?
(+ (risk-reward-to-pay-win 5/1) (risk-reward-to-pay-win 3/2))
(* (pay-win-to-risk-reward 5/6) (pay-win-to-risk-reward 7/8))
(+ (risk-reward-to-pay-win 5/1) (pay-win-to-risk-reward 7/8))
(* (pay-win-to-risk-reward 5/6) (risk-reward-to-pay-win 3/2))
5/6 ; (Is it a pay-win, or a risk-reward?)
That's not defined (and I have no intention to). As I said
I just found it _convenient_ to use rationals in this case. But
if this convenience comes at too high a price I'll reconsider.
It is convenient because you can go almost directly from a
probability measure to (yet a third kind of) ratio
(defun get-odds (p)
"given a probability between 0 and 1 of the event E, returns
the minimum value of the odds such that a bookie will break-even"
(rational (/ 1 p)))
(get-odds 0.5) => 2 (really: 2/1, ie n/m leading to m/n 1st kind
or n/m+n 2nd kind)
(get-odds 0.25) => 4 (really 4/1 ...)
(defmethod print-object ((self risk-reward) stream)
(if *print-readably*
(format stream "#.(make-instance '~S :risk ~S :reward ~S)"
(class-name (class-of self)) (risk self) (reward self))
(format stream "#<Risk/Reward ~A/~A>" (risk self) (reward self))))
I see your point. Thanks. But that's probably overkill for now.
Anyway I just archived a copy of it :-)
Many Thanks
--
JFB
.
- References:
- forcing representation of denominator 1?
- From: verec
- Re: forcing representation of denominator 1?
- From: Pascal Bourguignon
- forcing representation of denominator 1?
- Prev by Date: Re: forcing representation of denominator 1?
- Next by Date: Re: Call Lisp Program from vb.net
- Previous by thread: Re: forcing representation of denominator 1?
- Next by thread: Re: forcing representation of denominator 1?
- Index(es):
Relevant Pages
|