compute
A crate for scientific and statistical computing. For a list of what this crate provides, see FEATURES.md
. For more detailed explanations, see the documentation.
To use the latest stable version in your Rust program, add the following to your Cargo.toml
file:
// Cargo.toml
compute = "0.1"
For the latest version, add the following to your Cargo.toml
file:
=
compute
There are many functions which rely on linear algebra methods. You can either use the provided Rust methods (default), or use BLAS and/or LAPACK by activating the "blas"
and/or the "lapack"
feature flags in Cargo.toml
:
// example with BLAS only
compute =
Examples
Statistical distributions
use *;
let beta = new;
let betadata = b.sample_vec; // vector of 1000 variates
println!;
println!;
println!; // probability distribution function
let binom = new;
println!; // sample single value
println!; // probability mass function
Polynomial Regression and GLMs
use *;
let x = vec!;
let xd = design; // make a design matrix
let y = vec!;
let mut clf = new; // degree 2 (i.e. quadratic)
clf.fit; // linear least squares fitting
println!; // get model coefficients
let y_bin = vec!;
let mut glm = GLM new; // logistic regression
glm.set_penalty; // L2 penalty
glm.fit.unwrap; // fit with scoring algorithm (MLE), cap iterations at 25
println!; // get estimated coefficients
println!; // get covariance matrix for estimated coefficients
Time series models
use *;
let x = vec!;
let mut ar = AR new; // AR(1) model
ar.fit; // fit model with Yule-Walker equations
println!; // get model coefficients
println!; // forecast 5 steps ahead
Numerical integration
use *;
let f = ;
println!; // trapezoid integration with 100 segments
println!; // gaussian quadrature integration
println!; // romberg integration with tolerance and max steps
Signal processing
use *;
let sig = vec!;
let smoothed = savitzky_golay // LOESS, cubic smoothing with 5 points
let impulse = delta; // delta function with 5 steps and dt = 0.5
let res = convolve; // impulse response of signal
Linear algebra
use *;
let x = vec!;
let y = vec!;
println!; // calculate LU decomposition for x
println!; // solve 2x2 system of equations (each column of y is a system)
println!; // matrix multiply, transposing y
Data summary functions
use *;
use Vector;
let x = from;
println!;
println!;
println!;
println!;
Mathematical and statistical functions
use *;
println!;
println!