Changes between Version 1 and Version 2 of Ticket #11725


Ignore:
Timestamp:
08/24/11 21:30:20 (10 years ago)
Author:
spice
Comment:

Seems mostly fine to me. It would be easy to get bogged down as to what the default behaviour of QQbar.random_element() should be, but as implemented here this seems a reasonable first step. I did a test and found that with default parameters QQbar.random_element() returns zero about 15% of the time, nonzero real numbers about 60% of the time, and nonzero imaginary numbers about 7% of the time:

sage: L = []
sage: for j in range(5000):
....:     L.append(QQbar.random_element())
....:     
sage: RDF(L.count(0))/len(L)
0.133
sage: C = [r.imag() == 0 and r != 0 for r in L]
sage: RDF(C.count(True))/len(C)
0.6194
sage: D = [r.real() == 0 and r != 0 for r in L]
sage: RDF(D.count(True))/len(D)
0.066

The doctests all work and illustrate the new behaviour well. I fixed a few spelling errors, one grammatical error and added extra info in one other place:

- ``poly_degree`` - default: 2 - degree of the random 
   polynomial over the integers that the algebraic number 
   is a root of.

becomes

- ``poly_degree`` - default: 2 - degree of the random                                                     
    polynomial over the integers of which the returned                                                      
    algebraic number is a root.

And

For example if we do not include zero as a possible 
coefficient, there will never be a zero constant term, and 
thus never a zero root. ::

becomes

For example, current default behaviour of this method                                      
returns zero about 15% of the time; if we do not include zero as a                                        
possible coefficient, there will never be a zero constant term, and                                       
thus never a zero root. ::

I've uploaded the updated patch. These are trivial changes, but I suppose this should be re-reviewed before it can be given a positive review.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11725

    • Property Keywords random QQbar added
    • Property Reviewers changed from to Simon Spicer
  • Ticket #11725 – Description

    v1 v2  
    88
    99'''Apply''':
    10   1. [attachment:trac_11725-random-algebraic-numbers.patch]
     10  1. [attachment:trac_11725-random-algebraic-numbers2.patch]