Function get_random_integer_from_range_to_infinity

Source
pub fn get_random_integer_from_range_to_infinity(
    limbs: &mut RandomPrimitiveInts<u64>,
    range_generator: &mut VariableRangeGenerator,
    a: Integer,
    mean_bits_numerator: u64,
    mean_bits_denominator: u64,
) -> Integer
Expand description

Generates a random Integer greater than or equal to a lower bound $a$.

The mean bit length $m$ of the absolute values of the generated value is specified. $m$ is equal to mean_bits_numerator / mean_bits_denominator.

§Expected complexity

$T(n, m) = O(n + m)$

$M(n, m) = O(n / m)$

where $T$ is time, $M$ is additional memory, $n$ is mean_precision_numerator, and $m$ is mean_precision_denominator.

§Panics

Panics if mean_bits_numerator or mean_bits_denominator are zero, if $a > 0$ and their ratio is less than or equal to the bit length of $a$, or if they are too large and manipulating them leads to arithmetic overflow.

§Examples

use malachite_base::num::random::random_primitive_ints;
use malachite_base::num::random::VariableRangeGenerator;
use malachite_base::random::EXAMPLE_SEED;
use malachite_nz::integer::random::get_random_integer_from_range_to_infinity;
use malachite_nz::integer::Integer;

assert_eq!(
    get_random_integer_from_range_to_infinity(
        &mut random_primitive_ints(EXAMPLE_SEED.fork("limbs")),
        &mut VariableRangeGenerator::new(EXAMPLE_SEED.fork("rg")),
        Integer::from(-1000),
        20,
        1
    ),
    -2
)