Portable recurrence quantification analysis for finite trajectories
moon new demo
cd demo
moon add kekeshuo/moonrqa@0.1.0import {
"kekeshuo/moonrqa" @rqa,
}
options("is-main": true)fn main {
let t = @rqa.embed([0.0, 1.0, 0.0, 1.0, 0.0], 2, 1).unwrap()
let r = @rqa.recurrence(t, 0.0, @rqa.Chebyshev, 0, 16).unwrap()
let q = r.quantify(2, 2).unwrap()
println(q.to_json().stringify())
}git clone https://github.com/kekeshuo/moonrqa.git
cd moonrqa
moon run examples/signal
moon run examples/regime
moon run examples/couplingpython scripts/verify_workflows.py --target wasm-gclet t = @rqa.trajectory_csv("x,y\n0,1\n1,0\n0,1\n", true).unwrap()
let scaled = t.standardize().unwrap()
let chosen = @rqa.recurrence_at_rate(scaled, 0.4, @rqa.Euclidean, 0, 9).unwrap()
let summary = chosen.matrix.quantify(2, 2).unwrap()
let svg = chosen.matrix.to_svg(8, "观测状态", 9).unwrap()
ignore(summary)
ignore(svg)let a = @rqa.embed([0.0, 1.0, 2.0], 1, 1).unwrap()
let b = @rqa.embed([9.0, 0.0, 1.0, 2.0], 1, 1).unwrap()
let cross = @rqa.cross_recurrence(a, b, 0.0, @rqa.Chebyshev, 12).unwrap()
let profile = cross.lag_profile(-3, 3).unwrap()
let best = @rqa.best_lag(profile) // Some(1)
ignore(best)moon info
moon fmt --check
moon check --deny-warn
moon build --deny-warn
moon test --deny-warn
python scripts/verify_workflows.py --target wasm-gc
python scripts/verify_oracle.py --target wasm-gcpub(all) struct RateSelection {
threshold : Double
achieved_rate : Double
requested_rate : Double
matrix : Recurrence
} derive(Eq, Debug)fn Recurrence::block_densities(self : Recurrence, rows_per_block : Int, cols_per_block : Int) -> Result[Array[BlockDensity], RqaError]fn Recurrence::crop(self : Recurrence, row : Int, col : Int, height : Int, width : Int) -> Result[Recurrence, RqaError]fn Recurrence::lag_profile(self : Recurrence, minimum : Int, maximum : Int) -> Result[Array[LagPoint], RqaError]fn Recurrence::quantify(self : Recurrence, minimum_diagonal : Int, minimum_vertical : Int) -> Result[RqaSummary, RqaError]fn Recurrence::to_svg(self : Recurrence, cell_size : Int, title : String, max_cells : Int) -> Result[String, RqaError]pub(all) struct RqaSummary {
recurrent : Int
eligible : Int
recurrence_rate : Double?
determinism : Double
laminarity : Double
mean_diagonal : Double?
longest_diagonal : Int
divergence : Double?
diagonal_entropy : Double
trapping_time : Double?
longest_vertical : Int
vertical_entropy : Double
mean_return_gap : Double?
} derive(Eq, Debug)fn Trajectory::decimate(self : Trajectory, stride : Int, offset : Int) -> Result[Trajectory, RqaError]fn Trajectory::select_dimensions(self : Trajectory, indices : Array[Int]) -> Result[Trajectory, RqaError]fn analysis_json(t : Trajectory, threshold : Double, metric : Metric, theiler : Int, minimum_diagonal : Int, minimum_vertical : Int, max_cells : Int) -> Result[Json, RqaError]fn cross_recurrence(a : Trajectory, b : Trajectory, threshold : Double, metric : Metric, max_cells : Int) -> Result[Recurrence, RqaError]fn distance(a : Trajectory, i : Int, b : Trajectory, j : Int, metric : Metric) -> Result[Double, RqaError]fn distances(a : Trajectory, b : Trajectory, metric : Metric, max_cells : Int) -> Result[Array[Array[Double]], RqaError]fn recurrence(a : Trajectory, threshold : Double, metric : Metric, theiler : Int, max_cells : Int) -> Result[Recurrence, RqaError]fn recurrence_at_rate(t : Trajectory, target : Double, metric : Metric, theiler : Int, max_cells : Int) -> Result[RateSelection, RqaError]fn threshold_scan(t : Trajectory, thresholds : Array[Double], metric : Metric, theiler : Int, minimum_diagonal : Int, minimum_vertical : Int, work_budget : Int) -> Result[Array[ThresholdSummary], RqaError]fn window_rqa(t : Trajectory, size : Int, step : Int, threshold : Double, metric : Metric, theiler : Int, minimum_diagonal : Int, minimum_vertical : Int, work_budget : Int) -> Result[Array[WindowSummary], RqaError]Install
Download zipPortable recurrence quantification analysis for finite trajectories