# Ticket #3014(closed defect: fixed)

Opened 5 years ago

## [with patch, with positive review] ZZ.random_element -- corrupted docstring (easy to fix)

Reported by: Owned by: was mabshoff major sage-3.0.1 documentation

### 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.
```

## 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)

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.
```

### comment:2 Changed 5 years ago by gfurnish

• Summary changed from [with patch, needs review] ZZ.random_element -- corrupted docstring (easy to fix) to [with patch, with positive review] ZZ.random_element -- corrupted docstring (easy to fix)

applies cleanly and passes doctests

### comment:3 Changed 5 years ago by mabshoff

• Status changed from assigned to closed
• Resolution set to fixed

Merged in Sage 3.0.1.alpha0

Note: See TracTickets for help on using tickets.