-
-
Notifications
You must be signed in to change notification settings - Fork 673
Closed
Description
The AA.random_element()
method only ever returns integers
among -2, -1, 0, 1, 2:
sage: ' '.join(str(AA.random_element()) for i in range(100))
2 0 0 2 1 2 -1 0 -2 -2 -2 0 -2 0 2 -1 1 0 0 1 1 -1 2 -1 0 2 1
0 0 2 1 2 0 -1 -2 -2 -1 2 -2 1 -1 -2 -2 2 -1 0 1 -1 2 2 0 -2
-1 -1 1 -2 2 0 2 -2 0 -2 1 -2 0 -2 -2 -2 -1 -2 -1 2 0 0 1 0 0
-2 0 -1 2 -2 0 -2 2 -1 -1 1 1 -2 -1 0 -2 -2 -1 2 -2 -1 -2 -2
That's a bit un-random, even by Sage standards.
A simple improvement would be to return the real part
of QQbar.random_element()
:
sage: [QQbar.random_element().real() for i in range(5) ]
[-5.372281323269015?,
-0.2000000000000000?,
0.50000000000000000?,
-0.50000000000000000?,
0.1906845620110298?]
Component: algebra
Author: Ben Livingston, Michael Orlitzky
Branch/Commit: 94c07ba
Reviewer: Lorenz Panny
Issue created by migration from https://trac.sagemath.org/ticket/30875