Dear Robin
Actually you are working with machine precision, i.e., eps(10^-16) in
double precison.
it means that 1+eps == 1 in double precision.
try
from mpmath import *
10^-16*mp.rand()
or, as you have coded

from mpmath import *
mp.dps = 30
(mpf(1.0)+10^-16*mp.rand())-mpf(1.0)


On Thu, Jul 26, 2012 at 3:10 PM, robin hankin <[email protected]>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?
>
> thanks
>
>
> --
> Robin Hankin
> Uncertainty Analyst
> [email protected]
>
> --
> 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-support
> URL: http://www.sagemath.org
>



-- 
Ajay Rawat
Kalpakkam, IGCAR

-------------------------------------------------------------------------
Save Himalayas....
-------------------------------------------------------------------------

-- 
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-support
URL: http://www.sagemath.org

Reply via email to