[alicebot-archcomm] more random <random>

Jon Baer alicebot-archcomm@list.alicebot.org
Mon, 29 Apr 2002 00:06:49 -0400


The problem here is that this type of function is going to have to be declared
and voted upon and introduced into AIML 2.x or something ... but Id like to make
some comments on what Id like to see (personal opinion coming up here, be
prepared):

First, Id like to see it all stay within the <random> parent tag and not have any
more tags introduced because I (like probably many here) already see something
like a Random/List Framework within that could be abstract for all
implementations.  So in other words work within the <random><li> realm and expand
with attributes.

Second, there are some shortcuts Id like to see but not sure how well this works
considering it might have to use a scripting language of some kind, but something
where you can test a random item before hand ... psuedo code:

random
(test an expression) one (break)
(test an expression) two (break)
(test an expression) three (break)
(default) four (break)
end of random

I find this rather complex as a shortcut but Im trying to determine if <random>
is most like even needed because its really just a random selection upon a list.
I think "shuffling" is more of a breakdown of the type of selection upon the
list.  Here are some I can think of:

random - selecting only one in the list equally
random - selecting only one true statement from an expression
random - shuffling, selecting one (and maybe) adjusting its users value to false
within the list
straight list - pick first true and break
straight list - pick all true
straight list - shuffling, picking one starting from top/bottom of stack

The card analogy is good use but I think only if you apply the color dimension
(red = true, black = false) and work ur way around.

Then there is the issue of weighting each item in the list. :-\

- Jon


"Yuri A. Tijerino" wrote:

> I believe I started the most recent Random threat in the list.  I agree with
> Noel, I think there is a need for a function (whether it is <random> or not
> I don't care) that allows the bot to choose <li>s that have not previously
> been chosen before.  I think taht a new <shuffle> function or changing the
> current <random> function so that it implements "random selection without
> replacement" should do.  I think the math or statistics can be solved once
> we have defined what it should do.
>
> >From a bot developer point of view I would like to see a function <Function>
> that randomly selects an item from a list of elements, but on the next time
> around selects a different element randomly until all elements have been
> selected during a session.  It would be desireable that once all elements
> have been selected once, then the function would start selecting again from
> the same set.
>
> The closest analogy I can think of is a deck of cards.  Lets say the deck
> has 10 cards for convenience.
> First shuffle the deck and select one card.  Put the card on a separate
> deck.
> Now shuffle the original deck and select another card.  Put the card on the
> separate deck.
> Repeat until all cards on the original deck have been exhausted.
> Now begin the process again with the second deck creating another deck.
>
> This is the kind of function that I think would make conversations with bots
> more interesting, specially with the number of items in the function is not
> so large.
>
> Yuri
>
> ----- Original Message -----
> From: "Noel Bush" <noel@alicebot.org>
> To: "Alicebot and AIML Architecture Committee"
> <alicebot-archcomm@list.alicebot.org>
> Sent: Sunday, April 28, 2002 12:28 PM
> Subject: Re: [alicebot-archcomm] more random <random>
>
> > I am just reviewing the recent discussion on the general list, which I
> > should have done before my first post....in any case, it seems to me
> > that maybe the discussion might have gotten sidetracked on the question
> > of sets and lists in AIML, which is interesting but perhaps not
> > essential for what some people are looking for.
> >
> > The <arb> (or <arbitrary>, in the interest of avoiding obscurity) idea
> > seems really nice, but can't it be seen as a more advanced topic, one we
> > could get on to after providing a simpler <shuffle> that provides random
> > selection without replacement (now that I know the preferred term :-) )?
> >
> > On Sun, 2002-04-28 at 23:20, Dr. Richard S. Wallace wrote:
> > > Yep.  That's called random selection without replacement.
> > >
> > > The classic example is a shuffled deck of cards.  After you choose the
> seven
> > > of hearts, you cannot choose the seven of hearts again.
> > >
> > > Rich
> > > ----- Original Message -----
> > > From: "Noel Bush" <noel@alicebot.org>
> > > To: "Alicebot and AIML Architecture Committee"
> > > <alicebot-archcomm@list.alicebot.org>
> > > Sent: Sunday, April 28, 2002 12:17 PM
> > > Subject: Re: [alicebot-archcomm] more random <random>
> > >
> > >
> > > > I'm always immediately ready to believe that I'm the stupidest person
> in
> > > > the room, and that with every word out of my mouth I only add more
> > > > evidence that I'm utterly incompetent to express any thought or
> > > > opinion.  But that doesn't stop me from hoping that someone with more
> > > > expertise will come along and help give form to the formless, so to
> > > > speak.
> > > >
> > > > Do you have a prediction, mystical intuition, rock-solid proof,
> > > > anything, regarding something like "shuffle" and whether it's needed?
> > > > People who are building various bots for different applications seem
> to
> > > > be expressing a need.  Can someone who has already picked up several
> > > > statistics books provide some articulation to this need?
> > > >
> > > > On Sun, 2002-04-28 at 23:06, Dr. Richard S. Wallace wrote:
> > > > > My suggestion is to pick up a statistics book.
> > > > >
> > > > > Rich
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Noel Bush" <noel@alicebot.org>
> > > > > To: "Alicebot and AIML Architecture Committee"
> > > > > <alicebot-archcomm@list.alicebot.org>
> > > > > Sent: Sunday, April 28, 2002 12:02 PM
> > > > > Subject: Re: [alicebot-archcomm] more random <random>
> > > > >
> > > > >
> > > > > > Thanks, John and Rich, for the informative replies.
> > > > > >
> > > > > > I guess my concern has to do with an unanswered requirement that
> seems
> > > > > > to be lurking, not the nature of randomness itself.  The point
> about
> > > > > > never finding an even distribution in a small sample is definitely
> > > > > > important.  And it helps me to understand better the need for a
> > > > > > variation on the <random> theme, as was recently discussed on the
> > > > > > mailing list.
> > > > > >
> > > > > > As in,
> > > > > >
> > > > > > <shuffle>
> > > > > >   <li>One thing.</li>
> > > > > >   <li>Another thing.</li>
> > > > > >   <li>And so on.</li>
> > > > > > </shuffle>
> > > > > >
> > > > > > In which one item is chosen each time, "randomly" (without further
> > > > > > discussing what that is), and then the same element will not be
> chosen
> > > > > > again in the same bot-user context until all elements from the
> > > <shuffle>
> > > > > > have been "used up".
> > > > > >
> > > > > > I think this meets a need for what people would tend to mislabel
> > > > > > "random" (myself included).  It could be that this function is
> even
> > > more
> > > > > > needed than an actual <random>, since people are actually seeking
> a
> > > way
> > > > > > to create "varied, not-so-repetitive" responses, not really
> something
> > > > > > that corresponds to a mathematical definition of random.
> > > > > >
> > > > > > On Sun, 2002-04-28 at 20:30, John Foderaro wrote:
> > > > > > >
> > > > > > >
> > > > > > > >> The problem is that if two different <random> elements are
> > > > > > > >> imagined to each have an independent random "space", tying
> all of
> > > > > their
> > > > > > > >> choices to the same sequence of pseudo-random numbers really
> > > throws a
> > > > > > > >> wrench into the works.
> > > > > > >
> > > > > > >  I know what you're saying but I don't think there is anything
> to
> > > worry
> > > > > > > about.  Random number generators will produce a nice even
> > > distribution
> > > > > > > but only over a very large number of samples.  If you're asking
> > > > > > > for a random number between 0 and 4 (inclusive) and call random
> 5
> > > > > > > times you almost certainly won't get each number chosen once.
> > > > > > > And that's the correct result since the odds of that happening
> > > > > > > if the random number generator were truly random is very small.
> > > > > > >
> > > > > > > I wrote little test program to show this:
> > > > > > >
> > > > > > > If I chose 5 random numbers I get one 2, two 3's and 2 4's.
> > > > > > >
> > > > > > > cl-user(31): (testit :count 5)
> > > > > > > 0: 0  0.0d0
> > > > > > > 1: 0  0.0d0
> > > > > > > 2: 1  0.2d0
> > > > > > > 3: 2  0.4d0
> > > > > > > 4: 2  0.4d0
> > > > > > >
> > > > > > >
> > > > > > > If I chose one million random numbers I get this distribution.
> > > > > > > Now the distribution is very nice over the 5 possible numbers:
> > > > > > >
> > > > > > > cl-user(32): (testit :count 1000000)
> > > > > > > 0: 199398  0.199398d0
> > > > > > > 1: 199834  0.199834d0
> > > > > > > 2: 200394  0.200394d0
> > > > > > > 3: 200158  0.200158d0
> > > > > > > 4: 200216  0.200216d0
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Suppose that after every 7th random number I obtain I call
> > > > > > > the random number generator and throw away the value.  This is
> > > > > > > simulating the case of running another <random> tag with a
> > > > > > > different number of elements.
> > > > > > >
> > > > > > > We still end up with a nice distribution:
> > > > > > >
> > > > > > > cl-user(34): (testit :count 1000000 :toss-out 7)
> > > > > > > 0: 200119  0.200119d0
> > > > > > > 1: 200194  0.200194d0
> > > > > > > 2: 199914  0.199914d0
> > > > > > > 3: 199833  0.199833d0
> > > > > > > 4: 199940  0.19994d0
> > > > > > >
> > > > > > >
> > > > > > > So I don't think there is any need to create multiple
> independent
> > > > > > > random number sequences, one for each <random> tag.
> > > > > > >
> > > > > > >
> > > > > > > --john foderaro
> > > > > > >
> > > > > > > ps. here's my test code
> > > > > > >
> > > > > > > (in-package :user)
> > > > > > >
> > > > > > > (defvar results (make-array 5))
> > > > > > >
> > > > > > > (defun testit (&key (count 10000) (toss-out 0))
> > > > > > >   (dotimes (i (length results)) (setf (svref results i) 0))
> > > > > > >
> > > > > > >   (dotimes (i count)
> > > > > > >
> > > > > > >     ; throw out a random result periodically
> > > > > > >     (if* (and (> toss-out 0)
> > > > > > >       (zerop (mod i toss-out)))
> > > > > > >        then (random (+ (length results) 4)))
> > > > > > >
> > > > > > >     ; now collect some random info
> > > > > > >     (incf (svref results (random (length results)))))
> > > > > > >
> > > > > > >   (dotimes (i (length results))
> > > > > > >     (format t "~d: ~d  ~s~%"
> > > > > > >     i
> > > > > > >     (svref results i)
> > > > > > >     (/ (float (svref results i) 1.0d0) count)))
> > > > > > >   )
> > > > > > > _______________________________________________
> > > > > > > alicebot-archcomm mailing list
> > > > > > > alicebot-archcomm@list.alicebot.org
> > > > > > > http://list.alicebot.org/mailman/listinfo/alicebot-archcomm
> > > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > alicebot-archcomm mailing list
> > > > > > alicebot-archcomm@list.alicebot.org
> > > > > > http://list.alicebot.org/mailman/listinfo/alicebot-archcomm
> > > > >
> > > > > _______________________________________________
> > > > > alicebot-archcomm mailing list
> > > > > alicebot-archcomm@list.alicebot.org
> > > > > http://list.alicebot.org/mailman/listinfo/alicebot-archcomm
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > alicebot-archcomm mailing list
> > > > alicebot-archcomm@list.alicebot.org
> > > > http://list.alicebot.org/mailman/listinfo/alicebot-archcomm
> > >
> > > _______________________________________________
> > > alicebot-archcomm mailing list
> > > alicebot-archcomm@list.alicebot.org
> > > http://list.alicebot.org/mailman/listinfo/alicebot-archcomm
> > >
> >
> >
> > _______________________________________________
> > alicebot-archcomm mailing list
> > alicebot-archcomm@list.alicebot.org
> > http://list.alicebot.org/mailman/listinfo/alicebot-archcomm
> >
> >
>
> _______________________________________________
> alicebot-archcomm mailing list
> alicebot-archcomm@list.alicebot.org
> http://list.alicebot.org/mailman/listinfo/alicebot-archcomm