Closed jmarshrossney closed 3 years ago
I was wondering if we can do something better for the PDF. I mean take the uniform distr for example:
@property
def pdf(self):
x = torch.linspace(self.x_min, self.x_max, 10000)
dens = 1 / (self.x_max - self.x_min)
return x, torch.zeros_like(x) + dens
why are we generating 10000 points to plot a straight horizontal line? Is having x and f(x) the best thing here?
I think that if PDF was just an actual function, so in this case:
def pdf(self, x):
dens = 1 / (self.x_max - self.x_min)
return (x >= self.x_min)*(x <= self.x_max)*dens
it might be neater.
The difficulty then is that the plot function would have to work out the x to feed into the function which for the higher dimension distributions would also need to be multidimensional (which is possible with linspace) but also with the dimension on the expected axis, with some kind of convention. In the end it might not make it any neater
why are we generating 10000 points to plot a straight horizontal line? Is having x and f(x) the best thing here?
Yep it's nuts. Brain was miles behind as fingers were typing.
I think all of these pdf
properties could be improved, potentially following the structure of scipy.stats.rv_continuous. But the only purpose they currently serve is to plot the target density when we're training against a simple distribution..
Fixes mistake which prevents the target pdf being plotted alongside the base and model distributions, if the target pdf is known.