skills/timeseries/quaternion-angular-velocity/SKILL.md
Derive angular velocity from consecutive quaternion frames via relative rotation and rotvec conversion
npx skillsauth add wenmin-wu/ds-skills timeseries-quaternion-angular-velocityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When a sensor provides orientation as quaternions but not angular velocity directly, derive it from consecutive frames: compute the relative rotation between frames, convert to rotation vector, and divide by time delta. Useful as a feature for gesture/activity recognition.
import numpy as np
from scipy.spatial.transform import Rotation as R
def angular_velocity_from_quats(quaternions, dt=1/200):
"""Derive angular velocity from consecutive quaternions.
Args:
quaternions: (N, 4) orientation [x, y, z, w]
dt: time between samples (seconds)
Returns:
(N, 3) angular velocity [wx, wy, wz] in rad/s
"""
n = len(quaternions)
omega = np.zeros((n, 3))
for i in range(n - 1):
r_t = R.from_quat(quaternions[i])
r_next = R.from_quat(quaternions[i + 1])
delta = r_t.inv() * r_next
omega[i] = delta.as_rotvec() / dt
omega[-1] = omega[-2] # fill last sample
return omega
np.linalg.norm(delta.as_rotvec()) gives scalar rotation angle between framesdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF