Very bad random?

Jun 19, 2012 at 4:11pm

Very bad random?

Hi guys,

I surely must do something wrong… Max’s [random] cannot be that bad…
Does anyone have a clue about what I’m doing wrong in this patch? (ratio should asymptotically go to 0.2, but it doesn’t – at all…)
It happens both in Max 5 and Max 6.

Thanks,
Daniele

– Pasted Max Patch, click to expand. –
#46098
Jun 19, 2012 at 5:30pm

Interesting. I have a couple of ways of getting similar results. However, the histogram is pretty flat.

– Pasted Max Patch, click to expand. –
#166066
Jun 19, 2012 at 6:11pm

@Daniele

Your patch calculates the ratio of values less than 0.2 vs. values greater 0.2 in the range of 0..1.
At equal distribution this ratio should be 20% vs. 80%, ie. 20/80 = 0.25 (!)
So there is nothing wrong with [random].

#166067
Jun 19, 2012 at 6:37pm

random() isn’t a great RNG, but that’s not the problem.

Your patch is comparing the number of values < 0.2 with the number of values > 0.2. Ideally, that will approach the ration 0.2 : 0.8. Which is, the last time I looked, 0.25.

If you want to get something approaching 0.2, you need to compare the count of bangs coming out of your [sel 1] against a count of bangs coming out of your [< 0.2] object (the latter could also be a count of bangs coming straight out of your qmetro, btw).

There is an additional, albeit very slight, potential skew in your calculations from the fact that you only trigger the division when [< 0.2] evaluates to true. You should probably divide on every new random derivate (ie, put a [pak] in front of the [/] object).

Here is a modified patch that does what you want. For comparison, on the right there is a version using Litter Power objects. If you don’t have Litter Power, they won’t instantiate. But you can still see the modified core patch, which keeps itself to bog-standard objects.

– Pasted Max Patch, click to expand. –
#166068
Jun 19, 2012 at 7:58pm

Excellent. I knew I was looking in the wrong place.

In this case, I should have been in the kitchen, looking for coffee.

#166069
Jun 20, 2012 at 10:22am

Of course…
what an stupid mistake!
Sorry for posting, and thanks for answering.

d

#166070
Jun 22, 2012 at 10:50am

Actually, an easy mistake to make. And, once made, tricky to track down. It took me a few minutes. But once I’d made a version of your patch with a RNG that I know and trust ;-) I knew the problem had to be elsewhere.

#166071

You must be logged in to reply to this topic.