Sure, go for it! On 3/2/07, Robert Bradshaw <[EMAIL PROTECTED]> wrote: > > It's always bugged me that the default distribution for integers (and > rationals) is just a uniform distribution over some small range. What > if instead we chose the distribution ZZ.random_element() = floor(1/r) > where r is uniformly distributed in (-1,1). Then P(n) = 1 / (2 |n| (| > n| + 1)) for all n in Z-{0}. This gives mostly small numbers with the > occasional large ones thrown in at ever decreasing probabilities. > > A random rational could then be the ratio of two such integers. > > - Robert > > > On Mar 2, 2007, at 9:57 AM, William Stein wrote: > > > On 3/1/07, didier deshommes <[EMAIL PROTECTED]> wrote: > >> On 2/25/07, Craig Citro <[EMAIL PROTECTED]> wrote: > >>> Hey all, > >>> > >>> So I tried to generate a random polynomial today, and ran into > >>> some trouble. > >>> Here's what I did: > >>> > >>> sage: R.<x> = ZZ['x'] > >>> sage: R.random_element(3) > >>> <sage crashes> > >> > >> That is a nice edge case. I would say that or you just return 0 > >> everytime. Other rings seem to do that: > >> {{{ > >> sage: RR.random_element(0) > >> 0.000000000000000 > >> sage: QQ.random_element(0) > >> 0 > >> sage: RDF.random_element(0) > >> 0.143951483848 > >> }}} > > > >>> I traced back the problem, and it's not clear what the right fix > >>> is. So > >>> R.random_element makes a list of the appropriate length and calls > >>> ZZ.random_element(0) to fill it up. In the comments, it clearly > >>> explains why > > > > I've fixed this for sage > 2.2. The patch is attached in case you're > > interested. > > > > > > > <3251.patch> > > > > >
-- William Stein Associate Professor of Mathematics University of Washington --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com 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/ -~----------~----~----~----~------~----~------~--~---