Theano: linspace and quantile functions are missing

Hi, I am stuck trying to write the following code in pymc3 using theano. I don’t find linspace and quantile functions.
min_max_x = np.linspace(start=np.min(x), stop=np.max(x), num=100)
q = np.quantile(min_max_x, param)
Is there any workaround? Thanks!

1 Like


I think you should be able to use the functionality available in tt.arange() (which is much like np.arange()) to replicate the linspace() result. Would that work?

There’s also a PR under development to add those specifically: Added `Op`s for `np.linspace`, `np.logspace`, and `np.geomspace` by kc611 · Pull Request #779 · aesara-devs/aesara · GitHub

1 Like

Hi, the difference between arange and linspace is that arange doesn’t include the max value in the interval whereas linspace does. I would use tt.arange instead of linspace as a temporal workaround but it doesn’t solve the issue with quantile. This function doesn’t exist in theano.
Out of curiosity I checked if pytorch has linspace and quantile and it does…

Hi @twiecki
I need to extend the context of my question.
I am working on the MMM solution and trying to implement the saturation function described in the paper “bayesian methods for media mix modeling with carryover and shape effects”.
The function has two parameters: slope and half saturation point K.
The function is directly applicable to the data on 0-1 interval. But will not work when data is not normalized or even when it goes through adstock transformation because it may cause adstock higher than 1. One of the solutions I have found is to internally renormalize parameter K according to the quantile of the input data but I am stuck with linspace and quantile
Same issue is with logistic function.
As am not the one who is using pymc3 for MMM I am sure there exist some other solution.