Open ricardoV94 opened 1 year ago
Here do we want to use the np.median
itself or do we need to right the logic for median in pytensor?
Here do we want to use the
np.median
itself or do we need to right the logic for median in pytensor?
Good question, depends on how complicated the median code would look like if written in pure PyTensor. If it's messy we can just use np.median under the hood
I think using numpy under the hood is better. They even handle nans and have also allow inplace median by overwriting the input whenever required.
So a new op makes sense for this or just a function which calls np.median
under the hood will be enough?
For median
we can simply (but a bit naively) sort out and pick the middle index (or the average of the two middle ones if it's even length). There are better approaches, but this may be a good enough solution for now: https://rcoh.me/posts/linear-time-median-finding/
or just a function which calls np.median under the hood will be enough?
If using numpy code, it must always be inside an Op. Normal numpy code won't work with PyTensor symbolic variables (which are just placeholders and don't contain values yet)
or just a function which calls np.median under the hood will be enough?
If using numpy code, it must always be inside an Op. Normal numpy code won't work with PyTensor symbolic variables (which are just placeholders and don't contain values yet)
Ohk. So I'll try to write the median in pytensor itself since we want to avoid creating new ops
everytime right?
Ohk. So I'll try to write the median in pytensor itself since we want to avoid creating new ops everytime right?
Not anytime, but as much as possible!
Please describe the purpose of filing this issue
Equivalent symbolic methods to those are missing.
The Numpy
quantile
andpercentile
methods have too many options for theinterpolation
argument, and these are planned to be deprecated for a while now (see https://github.com/numpy/numpy/issues/10736). It should suffice to implement the default"linear"
interpolation.I am confident that these should not require any extra
Ops
.