code: @Override
      public double rand() {
          int mm = m;
          int nn = n;
  
          if (mm > N / 2) {
              // invert mm
              mm = N - mm;
          }
  
          if (nn > N / 2) {
              // invert nn
              nn = N - nn;
          }
  
          if (nn > mm) {
              // swap nn and mm
              int swap = nn;
              nn = mm;
              mm = swap;
          }
  
          if (rng == null) {
              if ((double) nn * mm >= 20 * N) {
                  // use ratio-of-uniforms method
                  rng = new Patchwork(N, mm, nn);
              } else {
                  // inversion method, using chop-down search from mode
                  rng = new Inversion(N, mm, nn);
              }
          }
  
          return rng.rand();
      }
docs: Uses inversion by chop-down search from the mode when the mean &lt; 20
  and the patchwork-rejection method when the mean &gt; 20.