Ask Your Question

Mark Bell's profile - activity

2020-02-17 01:04:35 +0200 received badge  Famous Question (source)
2019-07-14 00:20:02 +0200 received badge  Notable Question (source)
2019-07-14 00:20:02 +0200 received badge  Popular Question (source)
2019-03-13 15:31:14 +0200 received badge  Famous Question (source)
2018-02-03 19:28:10 +0200 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 15:16:22 +0200 received badge  Student (source)
2016-11-21 15:15:27 +0200 received badge  Notable Question (source)
2016-11-21 15:15:27 +0200 received badge  Popular Question (source)
2015-09-16 23:22:37 +0200 received badge  Scholar (source)
2015-09-16 21:48:17 +0200 received badge  Editor (source)
2015-09-16 21:47:01 +0200 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.