Code to compute the moving average of quaternions?
I have to compute the moving average of normal datas by follow which it's quite fast: def moving_average(a, n=15,axis=0) : ret = np.cumsum(a,axis=axis, dtype=float) ret[n:] = ret[n:] - ret[:-n] return ret[n - 1:] / n And I compute the moving average of quaternions by: def average_quat(Q, weights=None): ''' Averaging Quaternions. Arguments: Q(ndarray): an Mx4 ndarray of quaternions. weights(list): an M elements list, a weight for each quaternion. ''' # Form the symmetric accumulator matrix nb=Q.shape[0] if weights is None: weights=np.ones(nb)/nb # Get the eigenvector corresponding to largest eigen value return np.linalg.eigh(np.einsum('ij,ik,i->...jk', Q, Q, weights))[1][:, -1] def quat_moving_average(quat_list,n=15): nb=len(quat_list) return np.asarray([average_quat(quat_list[s:s+n]) for s in range(nb-n+1)]) Is there any better code to compute it?
1
# Users who requested the code (so far)
$8
Suggested price from buyers at which they’d buy
Potential revenues from requesters (actual revenues can be significantly higher)
Time of last request:on May 9, 2018
Tags:python
If you own such codes, please set up an offer and then invite users to it by clicking on «Invite to offer».
If you’re also be willing to buy those codes then click on «I’d also buy it» (no commitment to buy, but please only click when you’re serious about it).
Tell people about Sellcodes and get 20-40% on every resulting sale!