Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread LFS
Oh I agree Dave for several reasons (not least of all that Excel is not 
free, nor is it math based).
However I have to admit that I have not been happy with any non-Excel 
program for just "teaching" probability and statistics. 
Too complicated and the kiddies will give up. It took me 4 days to get this 
simulation in Sage going (I think it works now) and I gave up in GeoGebra 
without a fight. (Please don't think that I think Mathematica, et.al. any 
better. If anything they are even more complicated, not to mention costly.) 
I just want it to be relatively simple and mathematical to empirically test 
stuff :)


> But kids are used to Windows,so if you can encourage them to use a 
> non-Windows system, it would be useful as a side-benefit. 
>
> I'm not sure if it ever happened, but I know an 8-year old contacted 
> William about being a Sage developer. 
>
> Dave 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread David Kirkby
On 21 October 2012 13:04, LFS  wrote:
> yes - i finally saw that and took the call to the GDDinit out of the loop
> and this may be working, but I don't know how to explain this to the
> kiddies.
> Probably should have just stuck with Excel where I understand the
> generators. Too complicated by far.
> Thanks everyone for your help.

But kids are used to Windows,so if you can encourage them to use a
non-Windows system, it would be useful as a side-benefit.

I'm not sure if it ever happened, but I know an 8-year old contacted
William about being a Sage developer.

Dave

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread LFS
Thanks Dave - If I have a moment I will try the scatter plot method to 
check. That seems like a useful idea for student.
(This was just for a class lesson on testing the CLT and I am way over my 
time allotment :))
Thanks to both you and Dimitri for feedback!
Linda

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread David Kirkby
On 21 October 2012 12:03, LFS  wrote:
> Hiya Dave,
> What would the line of code look like to reseed it with the epoch thing each
> time I call it?
> Thanks so much,
>
> Linda


http://www.sagemath.org/doc/reference/sage/misc/randstate.html

says

If set_random_seed() is called with no arguments, then a new seed is
automatically selected. On operating systems that support it, the new
seed comes from os.urandom(); this is intended to be a truly random
(not pseudo-random), cryptographically secure number. (Whether it is
actually cryptographically secure depends on operating system details
that are outside the control of Sage.)


I tend to disagree with what's quoted there. The seed will be truely
random, but the sequence of numbers will not be. They will still be
preudo random.

Sage no doubt has endless ways of generating random numbers, and that
method might only work for one or more of the RNGs, but not all of
them.


Dave
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> 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.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread David Kirkby
On 21 October 2012 12:03, LFS  wrote:
> Hiya Dave,
> What would the line of code look like to reseed it with the epoch thing each
> time I call it?
> Thanks so much,
>
> Linda

The truth is I don't know off hand. I've spent a lot of time porting
Sage to Solaris, but have not used it much at all. I'm sure Python has
some code to get the get the seconds since the Epoch. One thing to
watch with this method, is if you call it too often (less than once
per second), you will be seeding it with the same number, and so get
the same sequence. I know someone who came unstuck. It wa ok on a slow
computer, but when he went to a fast computer, the things went all
wrong, as he was seeding it with the same numbers.

I'll try to find an example in the Sage manual. I'm sure it must have
something on this, but personally I don't know how to best do it. I'm
just relying on my experience of using pseudo-random numbers in C code
for Monte Carlo modelling.

dave

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread David Kirkby
One simple way to get a qualitative feel for the quality of random
numbers is to take them two at a tim, staring with the first two being
x1, y1. So you gererate:

x1, y1
x2, y2
x3, y3 etc

then plot a graph of x,y for all parts xn, yn

The graph should look like a scatter graph, with no obvious pattern.
There are more quantitive measures to check them. I'll give you a
reference to my PhD these if you want it, as I looked at random number
quality in some detail for Monte Carlo simulations.

Dave

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread LFS
Hiya Dave, 
What would the line of code look like to reseed it with the epoch thing 
each time I call it?
Thanks so much,
Linda

>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread David Kirkby
On 21 October 2012 11:42, LFS  wrote:
> Hiya Dimitri, It might actually be working. Not sure, but when I increased
> the number of sets ns, it does looks better. Still alot of repeats, but the
> histogram looks better. Linda

If there is a number of repeats, something is defnitely wrong. It
should either give you pseudo-random numbers if seeded properly, or a
100% preproducible set of numbers if seeded with a fixed seed.

It should not look better, but still not right. Something is wrong in
that case.

Dave

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] Re: Why don't I get random numbers?

2012-10-21 Thread David Kirkby
On 21 October 2012 11:30, LFS  wrote:
> Hiya Dmitrii
> Thanks so much for your quick reply, but I am still getting the same
> problem.

I don't know if this the best way in Sage, but it is common practice
to seed the random number generator from the number of seconds since
the Epoch (1/1/1970). So every time you seed it, you get a different
sequence.

Another option is to seed it with some bytes from /dev/random or
/dev/urandom. In fact, /dev/urandom gives about as good as you can get
for random numbers, as they are consider cryptographically secure.
However, if there is insufficent entropy in the system, /dev/urandom
will block, and give no data.

One advantage of using a pseudo random number generator is that it is
possible to repeat an experiment, using the same seed, and you will
get the same numbers. That's not possible if you use /dev/random or
/dev/urandom.

Dave

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.