Smarter way of doing this?

Anton Vredegoor anton at vredegoor.doge.nl
Thu Feb 5 06:29:02 EST 2004


Max M <maxm at mxm.dk> wrote:

>I don't understand what you mean. If I calculate the deviations from 
>what is expected, and use a large result set, I get very small deviations.

That's what I was afraid of, and I can't blame you for it :-)

>In my example below each letter should be occur 50% of the times of the 
>previous letter.
>
>Perhaps you mean that it should behave differently?

No, your code does what it should do and my code was just some
obviously wrong example to show what *kind* of solution I was after.

For example if my code is run with a list of probabilities like this:

[.1,.1,.1,.1,.1] it produces exactly the same distribution as your
code. However, with input like this: [2,1] (*different* probabilities)
it starts to diverge from your code. What I would like to do is to
replace this list [2,1] with the list of probabilities that would
cause my code to produce the same output as yours ...

So [2,1] ==> "some list of probabilities" and this *new* list is used
as multiplication factors in the  line with :

"max([(p*random(),c) for p,c in PC])"

I hope I succeeded in just getting the idea across instead of giving
the impression that my code works better, which obviously it doesn't. 
It *needs* some kind of transformation of the probabilities into an
other list ...

Anton



More information about the Python-list mailing list