You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there are even number of samples, the .median calls quantile(0.5) and that doesn't return the average (like numpy)
ChatGPT suggests the following:
defquantile(self, q: float|str) ->np.ndarray:
q=Quantile.parse(q).value# Assuming this returns a float between 0 and 1ifnot0<=q<=1:
raiseValueError("q should be between 0 and 1")
# Compute the exact positionpos=q* (self.num_samples-1)
# Get the integer part of the positionlower_idx=int(pos)
# Compute the weight for interpolationweight=pos-lower_idx# Handle the edge case where pos is the last indexiflower_idx+1<self.num_samples:
# Vectorized interpolationreturnself._sorted_samples[lower_idx] * (1-weight) +self._sorted_samples[lower_idx+1] *weightelse:
# If pos is exactly the last index, return the last samplereturnself._sorted_samples[lower_idx]
```
The text was updated successfully, but these errors were encountered:
Description
If there are even number of samples, the
.median
callsquantile(0.5)
and that doesn't return the average (like numpy)ChatGPT suggests the following:
The text was updated successfully, but these errors were encountered: