tail_compare¶
- tail_compare(diff: ndarray | float | int, obs_diff: ndarray | float | int, tails: int = 1) ndarray | bool[source][source]¶
Compare the difference between two groups to the observed difference.
This function applies the appropriate comparison based on the number of tails. The shapes of the two arrays must be broadcastable.
- Parameters:
diff (
array) – The difference between the two groups.obs_diff (
array) – The observed difference between the two groups.tails (
int, optional) – The number of tails to use. 1 for one-tailed, 2 for two-tailed.
- Returns:
larger – The boolean array indicating whether the difference between the two groups is larger than the observed difference.
- Return type:
array,shape (...,time)
Examples
>>> import numpy as np >>> rand = np.random.default_rng(seed=42) >>> diff1 = rand.random(5) - 0.5 >>> diff1 array([ 0.27395605, -0.06112156, 0.35859792, 0.19736803, -0.40582265]) >>> obs_diff1 = 0.25 >>> tail_compare(diff1, obs_diff1) array([ True, False, True, False, False]) >>> tail_compare(diff1, obs_diff1, tails=2) array([ True, False, True, False, True]) >>> tail_compare(diff1, obs_diff1, tails=-1) array([False, True, False, True, True]) >>> tail_compare(diff1, np.array([1, 2]) ... ) Traceback (most recent call last): ValueError: shape mismatch: objects cannot be broadcast to a single ...