On 10/07/2015 12:26 PM, Waldek Hebisch wrote:
>> If you are satisfied with random integers, then that must be stated
>> in the category documentation.
> 
> You mean that we should state explicitely that random elements need
> not exhaust the domain?

Yes, why not? If (as an implementor) I have such information, I know
that I don't need to bother with exhausting the domain.

>> In fact, I more and more get the impression that you don't actually
>> want "RandomChoice". What you want is a stream of elements of %
>> that do not repeat. Am I wrong?

> It would be nice if we could get non-repetition for free.

Well, if we had "Generator(X)" in SPAD, that would make it easier to
implement such non-repeating stream. Maybe one could also use Stream(X)
or even return a function of type ()->X that returns the "next" element.

> But it seems that user have more info how to handle possible 
> repetition.

Yes, maybe. But a function that returns some element in a somewhat
"uniform" distribution, would also have to take care of repeating elements.

> OTOH merely having non-repeating sequence is not enough.

Can you say why? You mentioned gcd and factorization. But I don't
understand. Primality testing would probably a different business.

> In practice we enlagre n as geometric sequence, so we need enough
> randomness.

Waldek, maybe I am the only one here on the list that does not get the
real purpose of your intention from the docstring that you have given.
Can you give more concrete examples of where you would like to apply
randomElement?

>> Well. That somehow sounds like you want to easily throw away "unlucky
>> primes".
>
> That separate topic.

Really? Well, for sure "deciding unluckyness" must be done by the user,
but otherwise (at least for gcd) it would be enough if randomElement
does not return the same (now known to be unlucky) element over and over
again.

I still don't get exactly what the purpose of your function is, but let
me try in documenting it and maybe I would change the signature a bit.

randomElement: Integer -> Union(() -> %, failed)
  ++ randomElement(n) randomly selects n elements from the domain
  ++ and returns a function "random" so that random() chooses randomly
  ++ among those n preselected elements. If the underlying domain does
  ++ not contain n elements then randomElement(n) returns failed.

That would be something I understand as an implementor.
Implementationwise, that does (of course) not mean, that the call
"randomElement(n)" first computes a *list* of n elements. Such details
are left open.

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to