I also have a patch for RDF.random_element.  I've pasted it in below for
comparison to ideas other people have.  The interface is still incomplete (I
wrote it in 5 minutes): I want to eventually provide an interface to all of
the probability distributions that GSL offers.

    def random_element(self, distribution = 'gaussian', parameters = [],
mean = None, sigma = None, min = None, max = None):

"""

        Return a random element of this real double field in the interval
[min,
max].




EXAMPLES:

            sage: RDF.random_element()

            -0.657233364114

            sage: RDF.random_element(min=100,
max=110)

            106.592535785

        """
        cdef float a, b
        import sage.gsl.probability_distribution
        # Eventually take mean and sigma into account if parameters ==
[]

        if min is not None and max is not None:
            a = min
            b = max
            return self._new_c((b-a)*random() + a)
        else:
            Dist =
sage.gsl.probability_distribution.RealDistribution(distribution,
parameters)
            return Dist.get_random_element()

David

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to