Skip to content

Commit

Permalink
docs(vrd): 📝 updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Mar 9, 2024
1 parent d88833c commit e0dce09
Showing 1 changed file with 70 additions and 44 deletions.
114 changes: 70 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ alt="Random (VRD) logo" height="261" width="261" align="right" />

# Random (VRD)

A Rust library for generating high-quality random numbers based on the
Mersenne Twister algorithm.
A Rust library for generating high-quality random numbers based on the Mersenne Twister algorithm.

*Part of the [Mini Functions][0] family of libraries.*

Expand Down Expand Up @@ -40,14 +39,15 @@ The index is incremented after each random number is generated. When the index r

## Features ✨

- Create new random number generator and seed it with a value.
- Design for speed and efficiency in mind.
- Generate random 32-bit unsigned integer within a given range.
- Provide random numbers of different types, including booleans, bytes, chars, doubles, floats, integers, and unsigned integers.
- Mutate the state of the random number generator.
- Produce pseudo-random number sequences that are different from each other.
- Regulate the randomness of the generated numbers, including the seed value and the number of bits used.
- Select a random element from a slice of values.
- Create new random number generator and seed it with a value
- Designed for speed and efficiency
- Generate random 32-bit unsigned integers within a given range
- Provide random numbers of different types, including booleans, bytes, chars, doubles, floats, integers, and unsigned integers
- Mutate the state of the random number generator
- Produce pseudo-random number sequences that are different from each other
- Regulate the randomness of the generated numbers, including the seed value and the number of bits used
- Select a random element from a slice of values
- Generate random numbers from various probability distributions, including uniform, normal, exponential, and Poisson

## Getting Started 🚀

Expand All @@ -63,15 +63,63 @@ Once you have the Rust toolchain installed, you can install `Random (VRD)` using
cargo install vrd
```

You can then run the help command to see the available options:
Add the following to your `Cargo.toml` file:

```toml
[dependencies]
vrd = "0.0.6"
serde = { version = "1.0.160", features = ["derive"] }
```

### Usage

```rust
use vrd::random::Random;

let mut rng = Random::new();
let rand_int = rng.int(1, 10);
println!("Random integer between 1 and 10: {}", rand_int);

let rand_float = rng.float();
println!("Random float: {}", rand_float);

let rand_bytes = rng.bytes(10);
println!("Random bytes: {:?}", rand_bytes);
```

### Examples

To get started with `Random (VRD)`, you can use the examples provided in the `examples` directory of the project.

To run the examples, clone the repository and run the following command in your terminal from the project root directory.

```shell
vrd --help
cargo run --example vrd
```

### Requirements
## Macros 🦀

The `Random (VRD)` library provides a set of macros that simplify the usage of the library. These macros offer a convenient way to generate random numbers of different types and distributions.

Here are some of the available macros:

- `rand_bool!(rng, probability)`: Generate a random boolean with the provided probability.
- `rand_bytes!(rng, length)`: Generate a vector of random bytes with the specified length.
- `rand_char!(rng)`: Generate a random character within the range 'a'..='z'.
- `rand_choose!(rng, values)`: Generate a random element from a slice of values.
- `rand_float!(rng)`: Generate a random float.
- `rand_int!(rng, min, max)`: Generate a random integer within the given range.
- `rand_uint!(rng, min, max)`: Generate a random 32-bit unsigned integer within the given range.
- `rand_double!(rng)`: Generate a random double.
- `rand_string!(rng, length)`: Generate a random string of the specified length.
- `rand_alphanumeric!(rng)`: Generate a random alphanumeric character.
- `rand_shuffle!(rng, slice)`: Shuffle a mutable slice randomly.
- `rand_weighted_choice!(rng, choices, weights)`: Select a random element from a slice based on the provided weights.
- `rand_normal!(rng, mu, sigma)`: Generate a normally distributed random number with the given mean and standard deviation.
- `rand_exponential!(rng, rate)`: Generate a random number from the exponential distribution with the given rate parameter.
- `rand_poisson!(rng, mean)`: Generate a random number from a Poisson distribution with the specified mean parameter.

The minimum supported Rust toolchain version is currently Rust **1.69.0** or later (stable). It is recommended that you install the latest stable version of Rust.
For more details on how to use these macros, please refer to the [documentation](https://docs.rs/vrd).

### Platform support

Expand Down Expand Up @@ -115,38 +163,14 @@ The minimum supported Rust toolchain version is currently Rust **1.69.0** or lat

The [GitHub Actions][11] shows the platforms in which the `Random (VRD)` library tests are run.

### Documentation
## Documentation 📚

> ℹ️ **Info:** Please check out our [website][1] for more information.
You can find our documentation on [docs.rs][9], [lib.rs][10] and [crates.io][8].
For detailed documentation, please visit:

## Usage 📖

To use the `Random (VRD)` library in your project, add the following to your `Cargo.toml` file:

```toml
[dependencies]
vrd = "0.0.6"
```

Add the following to your `main.rs` file:

```rust
extern crate vrd;
use vrd::*;
```

then you can use the functions in your application code.

### Examples

To get started with `Random (VRD)`, you can use the examples provided in the `examples` directory of the project.

To run the examples, clone the repository and run the following command in your terminal from the project root directory.

```shell
cargo run --example vrd
```
- [Website](https://vrdlib.one)
- [Docs.rs](https://docs.rs/vrd)
- [Lib.rs](https://lib.rs/crates/vrd)
- [Crates.io](https://crates.io/crates/vrd)

## Semantic Versioning Policy 🚥

Expand All @@ -173,6 +197,8 @@ A big thank you to all the awesome contributors of [vrd][6] for their help and s

A special thank you goes to the [Rust Reddit][13] community for providing a lot of useful suggestions on how to improve this project.

*Made with ❤️ by [Sébastien Rousseau](https://sebastienrousseau.com)*

[0]: https://minifunctions.com/ "MiniFunctions"
[1]: https://vrdlib.one "Random (VRD)"
[2]: https://opensource.org/license/apache-2-0/ "Apache License, Version 2.0"
Expand Down

0 comments on commit e0dce09

Please sign in to comment.