On 12/30/23 13:43, Georgi Guninski wrote:
Just FYI:

def testquotient2():
     set_random_seed(1);p=next_prime(10**120);Kx=Integers(p)['x']
     l=[Kx.random_element() for _ in range(100)]
     return l.count(0)
testquotient2()
27

Hi,

this is because PolynomialRing().random_element() takes an optional argument degree which should either be an integer greater or equal to -1, or an ordered pair of such integers which defines an integer range in which the degree is selected uniformly at random. By convention, degree -1 yields the 0 polynomial, degree 0 yields a constant non zero and so on.

By default, this argument is set to (-1, 2), which means that which 25% probability, degree -1 will be selected, and this is exactly what you observe with your experiment. But you can set degree to whatever suits you better, e.g. starting with 0 instead of -1 to avoid the 0 polynomial.

For more information:

https://doc.sagemath.org/html/en/reference/polynomial_rings/sage/rings/polynomial/polynomial_ring.html#sage.rings.polynomial.polynomial_ring.PolynomialRing_general.random_element

Best,

--
Maxime

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/401e78b2-baf4-4209-b9e1-1eec1e05e61f%40inria.fr.

Reply via email to