Ticket #3014 (closed defect: fixed)
[with patch, with positive review] ZZ.random_element -- corrupted docstring (easy to fix)
| Reported by: | was | Owned by: | mabshoff |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.0.1 |
| Component: | documentation | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
sage: ZZ.random_element?
...
Return a random integer.
ZZ.random_element() -- return an integer using the default
distribution described below
ZZ.random_element(n) -- return an integer uniformly
distributed between 0 and n-1, inclusive.
ZZ.random_element(min, max) -- return an integer uniformly
destributed between min and max-1, inclusive.
The default distribution for ZZ.random_element() is based on
X = trunc(4/(5R)), where R is a random variable
uniformly distributed between -1 and 1. This gives
Pr(X = 0) = 1/5, and Pr(X = n) =
2/(5|n|(|n|+1)) for n
eq 0. Most of the samples will be
small; -1, 0, and 1 occur with probability 1/5 each. But we
}}
Notice the messed up second t the last line!
This hit me during my demo today.
Attachments
Change History
comment:1 Changed 5 years ago by mabshoff
- Owner changed from tba to mabshoff
- Status changed from new to assigned
- Summary changed from ZZ.random_element -- corrupted docstring (easy to fix) to [with patch, needs review] ZZ.random_element -- corrupted docstring (easy to fix)
Note: See
TracTickets for help on using
tickets.


With the patch applied we get:
The default distribution for ZZ.random_element() is based on X = trunc(4/(5R)), where R is a random variable uniformly distributed between -1 and 1. This gives Pr(X = 0) = 1/5, and Pr(X = n) = 2/(5|n|(|n|+1)) for n neq 0. Most of the samples will be small; -1, 0, and 1 occur with probability 1/5 each. But we also have a small but non-negligible proportion of ``outliers''; Pr(|X| >= n) = 4/(5n), so for instance, we expect that |X| >= 1000 on one in 1250 samples.