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.2"
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_n; // vector of 1000 variates
println!; // analytic mean
println!; // analytic variance
println!; // probability distribution function
let binom = new;
println!; // sample single value
println!; // probability mass function
Linear algebra
use *;
let x = arange.ln_1p.reshape; // automatic shape detection
let y = from; // vector struct
let pd = x.t.dot; // transpose and matrix multiply
let jitter = eye * 1e-6; // elementwise operations
let c = .cholesky; // matrix decompositions
let s = c.solve; // linear solvers
println!;
Linear models
use *;
let x = vec!;
let y = vec!;
let n = y.len;
let xd = design;
let mut glm = GLM new; // logistic regression
glm.set_penalty; // L2 penalty
glm.fit.unwrap; // with fit scoring algorithm (MLE)
let coef = glm.coef.unwrap; // get estimated parameters
let errors = glm.coef_standard_error.unwrap; // get errors on parameters
println!;
println!;
Optimization
use *;
// define a function using a consistent optimization interface
// set up and run optimizer
let init = ;
let optim = with_stepsize;
let popt = optim.optimize;
println!;
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
Data summary functions
use *;
use Vector;
let x = from;
println!;
println!;
println!;
println!;
Mathematical and statistical functions
use *;
println!;
println!