BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Magpie · Integrate unevenly spaced observations

Integrate an increasing sample grid and flag under-sampled sections.

Integrate unevenly spaced observations

An arithmetic average ignores the spacing between measurements. Integrate on the supplied time grid and flag large gaps. A constant value of two across four time units gives an area of eight. The largest interval exceeds the allowed two-unit gap.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-magpie.git
cd blyx-magpie
blyxc native-run project.blyx -- "0,1,4" "2,2,2" 2

API and return values

Returns [area, span-weighted mean, widest gap, exceeds gap limit]. Rejects duplicate or reversed sample times. Invalid input returns an empty vector.

ArgumentAccepted input
xVector of: finite number
yVector of: finite number
max_gappositive finite number

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
8
2
3
1
Open in the full playground →

Practice

Change x = [0, 2], y = [0, 2]. Predict the result, then run the program.

Hint

Returns [area, span-weighted mean, widest gap, exceeds gap limit]. Rejects duplicate or reversed sample times.

Worked solution

The result vector is [2, 1, 2, 0]. Compare its fields with the return layout in the API section.

Find

    let x = [0, 1, 4];

Replace with

    let x = [0, 2];

Find

    let y = [2, 2, 2];

Replace with

    let y = [0, 2];

Output after the change

2
1
2
0