Blyx

Moments

Statistics library · 0.1.0

Summarize paired observations as they arrive and merge statistics from independent batches.

Install with Conda

Create an environment containing Moments 0.1.0, its Blyx source and a runnable example. Run the second command with Blyx 0.2.1, Rust and a host linker installed.

conda create -y --prefix ./blyx-env --override-channels -c https://rahulchaube1.github.io/blyx-packages blyx-moments=0.1.0=0
blyxc native-run ./blyx-env/share/blyx/moments/main.blyx

To use this package in your application, copy share/blyx/moments/vendor/moments from the environment into your project's vendor directory.

Install the full collection with Homebrew or Scoop

Import into a Blyx project

Install Blyx 0.2.1, Rust 1.85 or newer and a host linker. From the directory containing your entry file, clone this tagged release.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-moments.git vendor/moments

Save this as main.blyx beside vendor and run blyxc native-run main.blyx.

use vendor::moments::moments;

fn main() {
    let morning = mom_summary([1, 2], [10, 12]);
    let afternoon = mom_summary([3], [14]);
    let day = mom_merge(morning, afternoon);
    println!(at(day, 0));
    println!(at(day, 2));
    println!(mom_sample_sd_y(day));
}

Expected output

3
12
2

API and input requirements

The state contains count, two means, two centered sums of squares and a cross-product. Merge disjoint batches only. Empty batches act as the identity. Sample standard deviation needs at least two observations.

APIUse
mom_empty(), mom_update(state, x, y)Create a state and add one observation.
mom_summary(xs, ys), mom_merge(left, right)Summarize vectors or combine batches in constant additional state.
mom_sample_sd_y(state)Read the sample standard deviation of the second variable.

Develop and contribute

Open the tagged source to read the implementation and examples. Include the smallest reproducible Blyx program, compiler version and expected result when reporting an issue.