Skip to main content

Module quick

Module quick 

Source
Expand description

Quick and easy random generation for rapid prototyping

This module provides the simplest possible interface for common random generation tasks. Perfect for quick scripts, prototypes, and when you just need “some random numbers fast”.

§Examples

use scirs2_core::random::quick::*;

// Generate random numbers with minimal setup
let x = random_f64();              // Random number [0, 1)
let n = random_int(1, 100);        // Random integer [1, 100]
let b = random_bool();             // Random boolean

// Quick arrays
let data = random_vector(1000);    // 1000 random f64s
let matrix = random_matrix(10, 10); // 10x10 random matrix

// Quick sampling
let items = vec!["A", "B", "C", "D"];
let choice = pick_one(&items);      // Pick random item
let sample = pick_many(&items, 2);  // Pick 2 random items

Functions§

coin_flip
Coin flip - returns true or false with 50% probability
dice_roll
Dice roll - returns 1-6
dice_roll_sum
Roll multiple dice and return the sum
pick_many
Pick multiple random elements from a slice (with replacement)
pick_one
Pick a random element from a slice
random_bool
Generate a random boolean
random_bool_with_prob
Generate a random boolean with given probability of true
random_f32
Generate a random f32 in [0, 1)
random_f64
Generate a random f64 in [0, 1)
random_hex
Generate a random hex string of given byte length
random_int
Generate a random integer in the given range (inclusive)
random_int_vector
Generate a vector of random integers in the given range
random_matrix
Generate a 2D matrix of random f64s in [0, 1)
random_normal_matrix
Generate a 2D matrix of random normal values
random_percentage
Generate a random percentage (0.0 to 100.0)
random_text
Generate random text of given length (alphanumeric)
random_usize
Generate a random usize in the given range (inclusive)
random_vector
Generate a vector of random f64s in [0, 1)
shuffle
Shuffle a vector in place
shuffled
Create a shuffled copy of a vector
weighted_choice
Random choice with weights (simplified interface)