M2 icon indicating copy to clipboard operation
M2 copied to clipboard

Update random(QQ) to use standard uniform distribution

Open d-torrance opened this issue 1 year ago • 18 comments

This is split off from #3478. I think it makes sense to keep them separate since that deals with the Probability package and this deals with how rationals are randomly generated in the engine. The big change to the commits that were removed from that PR is the proposed probability distribution (no longer normal).

Rather than using the quotient of two discrete random variables with the uniform distribution on {1, ..., h}, we use the continuous uniform distribution on [0, 1], but rounded to the nearest rational number with denominator bounded by the number given by the Height option (default 10). For example:

i1 : random(QQ^3, QQ^3, Height => 3)

o1 = | 2/3 2/3 1/3 |
     | 1   1   2/3 |
     | 1   2/3 1/2 |

              3       3
o1 : Matrix QQ  <-- QQ

i2 : random(QQ^3, QQ^3)

o2 = | 1/8 1   7/8  |
     | 1/3 5/6 9/10 |
     | 1   3/4 1/7  |

              3       3
o2 : Matrix QQ  <-- QQ

i3 : random(QQ^3, QQ^3, Height => 100)

o3 = | 61/65 33/59 3/16  |
     | 15/26 7/26  31/39 |
     | 3/26  7/48  62/95 |

              3       3
o3 : Matrix QQ  <-- QQ

d-torrance avatar Sep 17 '24 23:09 d-torrance