Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grtlr/mbd-wasm
Rust implementation of the modified band depth that also compiles to JavaScript/WASM.
https://github.com/grtlr/mbd-wasm
data-depth rust statistics wasm
Last synced: about 5 hours ago
JSON representation
Rust implementation of the modified band depth that also compiles to JavaScript/WASM.
- Host: GitHub
- URL: https://github.com/grtlr/mbd-wasm
- Owner: grtlr
- License: apache-2.0
- Created: 2021-04-22T09:15:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-29T10:15:17.000Z (over 3 years ago)
- Last Synced: 2024-10-29T20:01:55.803Z (8 days ago)
- Topics: data-depth, rust, statistics, wasm
- Language: Rust
- Homepage:
- Size: 30.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mbd-wasm
[![GitHub Actions](https://github.com/grtlr/mbd-wasm/actions/workflows/ci.yml/badge.svg)](https://github.com/grtlr/mbd-wasm/actions/workflows/ci.yml)
[![npm version](https://img.shields.io/npm/v/mbd-wasm.svg)](https://www.npmjs.com/package/mbd-wasm)
[![Crates.io](https://img.shields.io/crates/v/mbd.svg)](https://crates.io/crates/mbd)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:
```rust
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:
```js
mbdWasm = (await require('[email protected]'))();
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
```