Ask Your Question

Mark Bell's profile - activity

2020-02-16 18:04:35 -0600 received badge  Famous Question (source)
2019-07-13 17:20:02 -0600 received badge  Notable Question (source)
2019-07-13 17:20:02 -0600 received badge  Popular Question (source)
2019-03-13 09:31:14 -0600 received badge  Famous Question (source)
2018-02-03 12:28:10 -0600 asked a question Uniform random choice of integer

I want to perform some statistical sampling and to do this I need to uniformly randomly choose an integer from [0, N) where $N \approx 10^{50}$. It appears that there are several plausible ways to do this in Sage:

1) randint(0, N-1)

However, the standard Python random library appears to have some non-uniformity, for example see this ticket.

2) import numpy; numpy.random.randint(0, N)

However, since N is so large, this raises

ValueError: high is out of bounds for int64

3) ZZ.random_element(0, N)

Do either of the issues that methods 1) and 2) suffer from apply to method 3)? That is, is 3) the correct way to integers uniformly at random?

2016-11-21 08:16:22 -0600 received badge  Student (source)
2016-11-21 08:15:27 -0600 received badge  Notable Question (source)
2016-11-21 08:15:27 -0600 received badge  Popular Question (source)
2015-09-16 16:22:37 -0600 received badge  Scholar (source)
2015-09-16 14:48:17 -0600 received badge  Editor (source)
2015-09-16 14:47:01 -0600 asked a question load a graph from a dot file

Sage allows me to get the representation of a Graph, G, in the dot language by using the method


I can even have this string written directly to a file by using:


Is there a way of reloading G from such a file? I tried doing

G = Graph('')

G = Graph(open(''))

G = Graph(open('').read())

Where the contents of '' are:

graph MyGraph{

foo -- {bar}

bar -- {foo; bas}

bas -- {bar}


But none of these worked.