def squared_dist(self, point_a, point_b, **kwargs): """Compute squared distance associated with the binomial Fisher Rao metric. Parameters ---------- point_a : array-like, shape=[...,] Point representing a binomial distribution (probability of success). point_b : array-like, shape=[...,] (same shape as point_a) Point representing a binomial distribution (probability of success). Returns ------- squared_dist : array-like, shape=[...,] Squared distance between points point_a and point_b. """ return (4 * self.n_draws * (gs.arcsin(gs.sqrt(point_a)) - gs.arcsin(gs.sqrt(point_b)))**2)
def tait_bryan_angles_from_quaternion_intrinsic_zyx(self, quaternion): assert self.n == 3, ('The quaternion representation' ' and the Tait-Bryan angles representation' ' do not exist' ' for rotations in %d dimensions.' % self.n) quaternion = gs.to_ndarray(quaternion, to_ndim=2) w, x, y, z = gs.hsplit(quaternion, 4) angle_1 = gs.arctan2(y * z + w * x, 1. / 2. - (x**2 + y**2)) angle_2 = gs.arcsin(-2. * (x * z - w * y)) angle_3 = gs.arctan2(x * y + w * z, 1. / 2. - (y**2 + z**2)) tait_bryan_angles = gs.concatenate([angle_3, angle_2, angle_1], axis=1) return tait_bryan_angles
def tait_bryan_angles_from_quaternion_intrinsic_xyz(self, quaternion): assert self.n == 3, ('The quaternion representation' ' and the Tait-Bryan angles representation' ' do not exist' ' for rotations in %d dimensions.' % self.n) quaternion = gs.to_ndarray(quaternion, to_ndim=2) w, x, y, z = gs.hsplit(quaternion, 4) angle_3 = gs.arctan2(2. * (x * y + w * z), w * w + x * x - y * y - z * z) angle_2 = gs.arcsin(-2. * (x * z - w * y)) angle_1 = gs.arctan2(2. * (y * z + w * x), w * w - x * x - y * y + z * z) tait_bryan_angles = gs.concatenate([angle_1, angle_2, angle_3], axis=1) return tait_bryan_angles
def tait_bryan_angles_from_quaternion_intrinsic_zyx(quaternion): """Convert quaternion to tait bryan representation of order zyx. Parameters ---------- quaternion : array-like, shape=[..., 4] Returns ------- tait_bryan_angles : array-like, shape=[..., 3] """ w, x, y, z = gs.hsplit(quaternion, 4) angle_1 = gs.arctan2(y * z + w * x, 1. / 2. - (x**2 + y**2)) angle_2 = gs.arcsin(-2. * (x * z - w * y)) angle_3 = gs.arctan2(x * y + w * z, 1. / 2. - (y**2 + z**2)) tait_bryan_angles = gs.concatenate([angle_1, angle_2, angle_3], axis=1) return tait_bryan_angles
def tait_bryan_angles_from_quaternion_intrinsic_xyz(quaternion): """Convert quaternion to tait bryan representation of order xyz. Parameters ---------- quaternion : array-like, shape=[..., 4] Returns ------- tait_bryan_angles : array-like, shape=[..., 3] """ w, x, y, z = gs.hsplit(quaternion, 4) angle_1 = gs.arctan2(2. * (-x * y + w * z), w * w + x * x - y * y - z * z) angle_2 = gs.arcsin(2 * (x * z + w * y)) angle_3 = gs.arctan2(2. * (-y * z + w * x), w * w + z * z - x * x - y * y) tait_bryan_angles = gs.concatenate([angle_1, angle_2, angle_3], axis=1) return tait_bryan_angles