#multidimensional #matrix #rand #ndarray

ndarray-rand

Constructors for randomized arrays. rand integration for ndarray.

13 releases (breaking)

✓ Uses Rust 2018 edition

new 0.10.0 Sep 10, 2019
0.9.0 Nov 19, 2018
0.8.0 Sep 1, 2018
0.7.0 Dec 29, 2017
0.1.0 Mar 29, 2016

#1 in #ndarray

Download history 207/week @ 2019-05-28 208/week @ 2019-06-04 374/week @ 2019-06-11 341/week @ 2019-06-18 298/week @ 2019-06-25 258/week @ 2019-07-02 253/week @ 2019-07-09 312/week @ 2019-07-16 115/week @ 2019-07-23 258/week @ 2019-07-30 210/week @ 2019-08-06 271/week @ 2019-08-13 324/week @ 2019-08-20 442/week @ 2019-08-27 351/week @ 2019-09-03

1,227 downloads per month
Used in 24 crates (22 directly)

MIT/Apache

505KB
9K SLoC

ndarray-rand

Constructors for randomized arrays: rand's integration with ndarray.

Example

Generate a 2-dimensional array with shape (2,5) and elements drawn from a uniform distribution over the (0., 10.) interval:

use ndarray::Array;
use ndarray_rand::RandomExt;
use ndarray_rand::rand_distr::Uniform;

fn main() {
    let a = Array::random((2, 5), Uniform::new(0., 10.));
    println!("{:8.4}", a);
    // Example Output:
    // [[  8.6900,   6.9824,   3.8922,   6.5861,   2.4890],
    //  [  0.0914,   5.5186,   5.8135,   5.2361,   3.1879]]
}

Dependencies

ndarray-rand depends on rand 0.7.

rand and rand-distr are re-exported as sub-modules, ndarray_rand::rand and ndarray_rand::rand_distr respectively. Please rely on these submodules for guaranteed version compatibility.

If you want to use a random number generator or distribution from another crate with ndarray-rand, you need to make sure that the other crate also depends on the same version of rand. Otherwise, the compiler may return errors saying that the items are not compatible (e.g. that a type doesn't implement a necessary trait).

Recent changes

0.10.0

  • Require rand 0.7
  • Require Rust 1.32 or later
  • Re-export rand as a submodule, ndarray_rand::rand
  • Re-export rand-distr as a submodule, ndarray_rand::rand_distr

Check Changelogs to see the changes introduced in previous releases.

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

Dependencies

~1MB
~19K SLoC