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 itemsFunctions§
- 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)