Jump to content

Probability in random functions


Recommended Posts

Greetings:

 

Working with the probability weighting control in random functions displays that they may be some value in revisiting the code to see if there may be a way to improve it.

What I am seeing:

 

(setf instr2 (flatten (rnd-unique n-bars pats2 :prob 0.89)))

Here "pats2" is a field of 32 values from 1 to 32. "n-bars" is 11 in this case.

 

A return of this function:

(26 27 16 19 31 17 20 29 24 6 5)

With the weighting of 0.89, I do not expect to see 6 or 5 in the result. In fact, with a higher number, such as 0.9, low numbers are returned often, but the result "should" be from only the higher numbers?

 

If one sets the weighting to 1.0, there is another kind of anomaly in the output:

 

OM 361 > rnd-unique :seed 138124
flatten
(32 31 30 29 28 27 26 25 24 23 22)

OM 362 > rnd-unique :seed 856981
flatten
(32 31 30 29 28 27 26 25 24 23 22)

 

Likewise setting the value to 0.0 results in the opposite result.

 

My intuition suggests that this may have to do with two factors: 1) the nature of the rnd-unique function itself - only selecting UNIQUE elements (no repeated values) and 2) the relatively small domain of the possible (32 in this case) combined with the number of results (11 in this case).  However, I am not sure.

 

I hope that these comments are helpful.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy