1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! Nonuniform pseudorandom number generation
//!
//! This library provides a suite of nonuniform random number generators
//! via bindings to the Numpy fork of RandomKit. It is approximately
//! equivalent to Numpy's `numpy.random` module. The API is loosely
//! based on that of the [`rand`](https://github.com/rust-lang/rand)
//! crate.
//!
//! This library is not suitable for cryptography.
//!
//! # Usage
//!
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! randomkit = "0.1"
//! ```
//!
//! and this to your crate root:
//!
//! ```rust
//! extern crate randomkit;
//! ```
//!
//! # Examples
//!
//! ## Standard normal distribution
//!
//! Sample 1000 numbers from the standard normal distribution (Gauss
//! distribution) with mean 0 and standard deviation 1.
//!
//! ```rust
//! extern crate randomkit;
//!
//! use randomkit::{Rng, Sample};
//! use randomkit::dist::Gauss;
//!
//! fn main() {
//! let mut rng = Rng::new().unwrap();
//! for _ in 0..1000 {
//! println!("{}", Gauss.sample(&mut rng));
//! }
//! }
//! ```
//!
//! ## Normal distribution
//!
//! Sample 1000 numbers from a normal distribution with mean 10 and
//! standard deviation 5.
//!
//! ```rust
//! extern crate randomkit;
//!
//! use randomkit::{Rng, Sample};
//! use randomkit::dist::Normal;
//!
//! fn main() {
//! let mut rng = Rng::from_seed(1);
//! let normal = Normal::new(10.0, 5.0).unwrap();
//! for _ in 0..1000 {
//! println!("{}", normal.sample(&mut rng));
//! }
//! }
//! ```
extern crate libc;
use mem;
use c_ulong;