Hi, On Thu, Jul 26, 2012 at 7:40 PM, robin hankin <hankin.ro...@gmail.com> wrote: > I am trying to generate random numbers and am running into roundoff > problems: > > RealDistribution('uniform', [1,1+1/10^16]).get_random_element()-1 > > This returns zero every time for me, something that is almost surely wrong. > I would expect a number chosen from the interval (0,1e-16). > > How do I make sage do what I want?
Does this help? sage: R = RealField(100) sage: R.random_element(1, 1+1/10^16) 1.0000000000000000745276341034 sage: R.random_element(1, 1+1/10^16) 1.0000000000000000899962307929 and so on. Note that if you try to use RR (which is the same as RealField(53)) you run into the same precision/roundoff problem as you had before. Hence the need to increase the working precision. Also note that R.random_element() can only do uniform distribution, so if you were hoping for something fancier this won't help. -- Best, Alex -- Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne http://aghitza.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org