Re: forcing representation of denominator 1?



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

.



Relevant Pages

  • Re: Probability of picking a positive rational number at random
    ... There _are_ distributions on the rationals, ... Specifying such a distribution is equivalent ... probability questions such as the ones you are asking, or, if a closed ... So obviously this density function yields a finite result when asked ...
    (sci.math)
  • Re: Random Rational?
    ... |>number has an even denominator"? ... the result is plainly not literally a probability. ... of a set of rationals under the height ordering. ... absolute value that had an even denominator in lowest terms tends toward ...
    (sci.math)
  • Re: Monkeys typing Shakespeare
    ... It makes little sense to say that the probability of ... choosing a rational is the same as the probability of choosing an ... That the irrationals are uncountable is hardly a reason to think that ... over all rationals in [0,1) of the probability of choosing any given ...
    (rec.puzzles)
  • Re: Factoring and rationals
    ... and _compute_ the empirical probability that the ... See the word "convention" in my original msg. ... there are several equally plausable enumerations to choose ... over rationals "chosen at random", and it looks messier to me too. ...
    (sci.crypt)
  • Re: Relative Cardinality
    ... >> with probability 0 it will be a rational. ... The set of rationals in is a measurable set with measure zero and ... the set of irrationals in ias a measurable set with measure 1. ... A uniform disribution on a countable set is not possible. ...
    (sci.math)