mbd

Crates.iombd
lib.rsmbd
version0.1.1
sourcesrc
created_at2021-04-22 12:27:55.902488
updated_at2021-05-29 10:13:53.639102
descriptionRust implementation of the modified band depth that also compiles to WASM.
homepagehttps://github.com/grtlr/mbd-wasm
repositoryhttps://github.com/grtlr/mbd-wasm
max_upload_size
id388118
size45,931
Jochen Görtler (grtlr)

documentation

README

mbd-wasm

GitHub Actions npm version Crates.io

A Rust implementation of the modified band depth that also compiles to WASM.

Usage

The library can be used a simple rust crate, by adding mbd = "*" to your Cargo.toml. Then, we can compute the modified band depth of the functional [2.0, 3.0, 4.0] as follows:

let data = vec![vec![4.0, 5.0, 6.0], vec![1.0, 2.0, 3.0]];
let mbd = ModifiedBandDepth::from_samples(&data);
assert_eq!(mbd.query(&[2.0, 3.0, 4.0]), 1.0);

Similarly, you can call the the same functionality from JavaScript:

mbdWasm = (await require('mbd-wasm@0.1.1'))();
const data = [[4.0, 5.0, 6.0], [1.0, 2.0, 3.0]]
const num_samples = data.length;
const num_timepoints = data[0].length;
const mbd = mbdWasm.ModifiedBandDepth.from_data_matrix(num_samples, num_timepoints, data.flat());
console.log(mbd.query([2.0, 3.0, 4.0])); // prints 1.0
Commit count: 15

cargo fmt