Half Baked Thoughts on implementing non-flat probability outcomes


This might demonstrate how new ideas can emerge from accidental insights you have about code you've written for a different purpose.

So below is a function I wrote called randLE(), which picks a random element from a list and outputs that one randomly selected slice based on a randomly selected index within a range.

The output can be of type string, or integer of float. The input list should be of the desired one type: (Left click on image to enlarge, backspace to return to original size image)


That got me thinking.
What if I had an input list that looked like this:

[0, 10, 1, 1, 9, 9, 2, 2, 2, 8, 8, 8, 3, 3, 3, 3, 7, 7, 7, 7, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5]

In other words the occurrences of the list elements are weighted.
There are: six 5's, five each of 4's and 6's, four each of 3's and 7's, three each of 2's and 8's,
two each 1's and 9's and one each of 0's and 10's. That tilts the probability distribution curve into having a triangle shape with selection of a 5 having the highest probabilit
y and 0 or 10 having the lowest.   ... TO BE CONTINUED

MORE TO EXPLORE

Comments

Popular posts from this blog

Links for Python Noobs

The Learn HOW to Learn Page

Welcome to Circular Import Hell