8000 GitHub - kchro3/mvn-rs: multivariate normal distribution (rust for wasm)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kchro3/mvn-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mvn-rs

Rust implementation of a multivariate normal distribution with WebAssembly bindings.

Building

To build the Rust library normally:

cargo build

To build the WebAssembly package (requires wasm-pack):

wasm-pack build -t node --release -- --features wasm

This will generate an npm package in the pkg directory that can be published to npm.

Usage

use mvn::MultivariateNormal;

let mean = vec![0.0, 0.0];
let cov = vec![1.0, 0.0, 0.0, 1.0];
let mvn = MultivariateNormal::new(mean, cov, 2);
let sample = mvn.sample();

JavaScript Interface

After building the WebAssembly package, you can access the distribution from Node.js:

const mvn = require('./mvn/pkg');
const dist = new mvn.MultivariateNormal([0, 0], [1, 0, 0, 1], 2);
console.log(dist.sample());

Benchmarks

Simple performance benchmarks can be run with:

npm run benchmark

This compares the WebAssembly implementation with a pure JavaScript fallback located in js/simple_mvn.js.

About

multivariate normal distribution (rust for wasm)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0