oarfish 0.6.1

A fast, accurate and versatile tool for long-read transcript quantification.
1
2
3
4
5
6
7
8
9
10
11
12
use rand::distributions::{Distribution, Uniform};
use rand::Rng;

/// Get a random uniform sample of `n` numbers in the range [0,n).
/// Duplicates are explicitly allowed. The numbers are returned in
/// sorted order.
pub fn get_sample_inds<R: Rng + ?Sized>(n: usize, rng: &mut R) -> Vec<usize> {
    let dist = Uniform::new(0, n);
    let mut inds: Vec<usize> = dist.sample_iter(rng).take(n).collect();
    inds.sort_unstable();
    inds
}