All Projects → al-jshen → compute

al-jshen / compute

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Scientific and statistical computing with Rust.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to compute

SciCompforChemists
Scientific Computing for Chemists text for teaching basic computing skills to chemistry students using Python, Jupyter notebooks, and the SciPy stack. This text makes use of a variety of packages including NumPy, SciPy, matplotlib, pandas, seaborn, NMRglue, SymPy, scikit-image, and scikit-learn.
Stars: ✭ 65 (+18.18%)
Mutual labels:  science, computing
adorad
Fast, Expressive, & High-Performance Programming Language for those who dare
Stars: ✭ 54 (-1.82%)
Mutual labels:  science, computing
Codemeta
Minimal metadata schemas for science software and code, in JSON-LD
Stars: ✭ 218 (+296.36%)
Mutual labels:  science
spinmob
Rapid and flexible acquisition, analysis, fitting, and plotting in Python. Designed for scientific laboratories.
Stars: ✭ 34 (-38.18%)
Mutual labels:  science
Homebrew Bio
🍺🔬 Bioinformatics formulae for the Homebrew package manager (macOS and Linux)
Stars: ✭ 237 (+330.91%)
Mutual labels:  science
Math Science Video Lectures
List of Science courses with video lectures
Stars: ✭ 219 (+298.18%)
Mutual labels:  science
Qvge
Qt Visual Graph Editor
Stars: ✭ 237 (+330.91%)
Mutual labels:  science
Opentrons
Software for writing protocols and running them on the Opentrons OT-2
Stars: ✭ 203 (+269.09%)
Mutual labels:  science
spectral-workbench.js
The JavaScript heart of Spectral Workbench; a Public Lab project to record, manipulate, and analyze spectrometric data.
Stars: ✭ 40 (-27.27%)
Mutual labels:  science
Resources
📖 Huge curated collection (archive) of links of Tech, Science, Economics, Politics, Life, Philosophy, Conferences, Videos and much more resources from everyday surfing. ⭐️ Since October 21, 2017.
Stars: ✭ 236 (+329.09%)
Mutual labels:  science
Awesome Datascience
📝 An awesome Data Science repository to learn and apply for real world problems.
Stars: ✭ 17,520 (+31754.55%)
Mutual labels:  science
Cwltool
Common Workflow Language reference implementation
Stars: ✭ 235 (+327.27%)
Mutual labels:  science
Stdlib
✨ Standard library for JavaScript and Node.js. ✨
Stars: ✭ 2,749 (+4898.18%)
Mutual labels:  science
Astropy
Repository for the Astropy core package
Stars: ✭ 2,933 (+5232.73%)
Mutual labels:  science
Abyss
🔬 Assemble large genomes using short reads
Stars: ✭ 219 (+298.18%)
Mutual labels:  science
ember-osf-preprints
OSF Preprints: The open preprint repository network
Stars: ✭ 38 (-30.91%)
Mutual labels:  science
Bibliometrix
An R-tool for comprehensive science mapping analysis. A package for quantitative research in scientometrics and bibliometrics.
Stars: ✭ 213 (+287.27%)
Mutual labels:  science
Reprozip
ReproZip is a tool that simplifies the process of creating reproducible experiments from command-line executions, a frequently-used common denominator in computational science.
Stars: ✭ 231 (+320%)
Mutual labels:  science
Ten Rules
Ten simple rules for better figures
Stars: ✭ 236 (+329.09%)
Mutual labels:  science
diffcalc
Diffcalc: a diffraction condition calculator for X-ray or neutron diffractometer control
Stars: ✭ 17 (-69.09%)
Mutual labels:  science

compute

Crates.io Documentation License

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
[dependencies]
compute = "0.2"

For the latest version, add the following to your Cargo.toml file:

[dependencies]
compute = { git = "https://github.com/al-jshen/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 = {version = "0.2", features = ["blas"]}

Examples

Statistical distributions

use compute::distributions::*;

let beta = Beta::new(2., 2.);
let betadata = b.sample_n(1000); // vector of 1000 variates

println!("{}", beta.mean()); // analytic mean
println!("{}", beta.var()); // analytic variance
println!("{}", beta.pdf(0.5)); // probability distribution function

let binom = Binomial::new(4, 0.5);

println!("{}", p.sample()); // sample single value
println!("{}", p.pmf(2));  // probability mass function

Linear algebra

use compute::linalg::*;

let x = arange(1., 4., 0.1).ln_1p().reshape(-1, 3);  // automatic shape detection
let y = Vector::from([1., 2., 3.]);  // vector struct
let pd = x.t().dot(x);               // transpose and matrix multiply
let jitter = Matrix::eye(3) * 1e-6;  // elementwise operations
let c = (pd + jitter).cholesky();    // matrix decompositions
let s = c.solve(&y.exp());           // linear solvers
println!("{}", s);

Linear models

use compute::prelude::*;

let x = vec![
    0.50, 0.75, 1.00, 1.25, 1.50, 1.75, 1.75, 2.00, 2.25, 2.50, 2.75, 3.00, 3.25, 3.50, 4.00,
    4.25, 4.50, 4.75, 5.00, 5.50,
];
let y = vec![
    0., 0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 1., 0., 1., 1., 1., 1., 1., 1.,
];
let n = y.len();
let xd = design(&x, n);

let mut glm = GLM::new(ExponentialFamily::Bernoulli); // logistic regression
glm.set_penalty(1.);                                  // L2 penalty
glm.fit(&xd, &y, 25).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!("{:?}", coef);
println!("{:?}", errors);

Optimization

use compute::optimize::*;

// define a function using a consistent optimization interface
fn rosenbrock<'a>(p: &[Var<'a>], d: &[&[f64]]) -> Var<'a> {
    assert_eq!(p.len(), 2);
    assert_eq!(d.len(), 1);
    assert_eq!(d[0].len(), 2);

    let (x, y) = (p[0], p[1]);
    let (a, b) = (d[0][0], d[0][1]);

    (a - x).powi(2) + b * (y - x.powi(2)).powi(2)
}

// set up and run optimizer
let init = [0., 0.];
let optim = Adam::with_stepsize(5e-4);
let popt = optim.optimize(rosenbrock, &init, &[&[1., 100.]], 10000);

println!("{:?}", popt);

Time series models

use compute::timeseries::*;

let x = vec![-2.584, -3.474, -1.977, -0.226, 1.166, 0.923, -1.075, 0.732, 0.959];

let mut ar = AR::new(1);             // AR(1) model
ar.fit(&x);                          // fit model with Yule-Walker equations
println!("{:?}", ar.coeffs);         // get model coefficients
println!("{:?}", ar.predict(&x, 5)); // forecast 5 steps ahead

Numerical integration

use compute::integrate::*;

let f = |x: f64| x.sqrt() + x.sin() - (3. * x).cos() - x.powi(2);
println!("{}", trapz(f, 0., 1., 100));        // trapezoid integration with 100 segments
println!("{}", quad5(f, 0., 1.));             // gaussian quadrature integration
println!("{}", romberg(f, 0., 1., 1e-8, 10)); // romberg integration with tolerance and max steps

Data summary functions

use compute::statistics::*;
use compute::linalg::Vector;

let x = Vector::from([2.2, 3.4, 5., 10., -2.1, 0.1]);

println!("{}", x.mean());
println!("{}", x.var());
println!("{}", x.max());
println!("{}", x.argmax());

Mathematical and statistical functions

use compute::functions::*;

println!("{}", logistic(4.));
println!("{}", boxcox(5., 2.);      // boxcox transform
println!("{}", digamma(2.));
println!("{}", binom_coeff(10, 4)); // n choose k
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].