Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composition of random variables and parameters #13

Open
ibab opened this issue Jan 30, 2015 · 8 comments
Open

Composition of random variables and parameters #13

ibab opened this issue Jan 30, 2015 · 8 comments
Milestone

Comments

@ibab
Copy link
Owner

ibab commented Jan 30, 2015

Users should be able to pass combinations of random variables and parameters to a model. This would allow them to build more models, e.g. for fitting a function to data. But how would this work?

x = var('x')
y = var('y')
a = par('a')
b = par('b')
sigma = par('sigma')
Normal(y, a * x + b, sigma)
@maxnoe
Copy link
Collaborator

maxnoe commented Jan 30, 2015

This is also needed for implementing the cdfs of the Distributions, needed for the statistical tests.

@ibab
Copy link
Owner Author

ibab commented Jan 30, 2015

Are you sure you can't do that by accessing the underlying theano variables with .tvar?

@maxnoe
Copy link
Collaborator

maxnoe commented Jan 30, 2015

Ah, that should help. But we could implement that in the classes themselves, like this:

def __mul__(self, object):
      object * self.tvar
def __rmul__(self, object):
     self.tvar * object

i'll implement this for all basic operations
http://stackoverflow.com/questions/6892616/python-multiplication-override

@ibab
Copy link
Owner Author

ibab commented Jan 30, 2015

It might be more elegant to return theano expressions directly from var and par.
Distribution would then need to be adjusted to work with that, but that would allow models like the one above.

@maxnoe
Copy link
Collaborator

maxnoe commented Jan 30, 2015

i overloaded the basic operators, kolmogorow smirnow tests works for now. We may find a more elegent solution .

@ibab
Copy link
Owner Author

ibab commented Jan 30, 2015

Then again, we will need to track extra information like bounds, so I don't see a way around implementing all the operators.
But what do you get if you combine a variable and a parameter?
Probably a variable if we want variables to be vectors and parameters to be scalars.

@ibab
Copy link
Owner Author

ibab commented Jan 30, 2015

Why did you memoize the function?
It would make much more sense to call it pdf_compiled like the others and return the compiled pdf.
You can then call self.pdf_compiled(...) to use it.

@maxnoe
Copy link
Collaborator

maxnoe commented Jan 30, 2015

I will change that

@ibab ibab modified the milestone: v0.1 Feb 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants