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

Add norms decorator #196

Closed
RaphaelS1 opened this issue Apr 9, 2020 · 8 comments
Closed

Add norms decorator #196

RaphaelS1 opened this issue Apr 9, 2020 · 8 comments

Comments

@RaphaelS1
Copy link
Collaborator

As the final structure of this decorator is unclear, for now it would be most sensible to write these functions using S3 dispatch notation, i.e. say the function is Pdf2Norm, then this would be written as:

<function>.<distribution> where <function> is the function implemented and <distribution> is the classname of the distribution, see listDistributions() for the full list. e.g. to implement the 2-norm of Binomial pdf:

Pdf2Norm.Binomial

For now these can be stored in a single script for each function class, e.g. Pdf2Norm.R, Cdf2Norm.R, each containing the specific functions for each distribution.

@aintoha We will discuss here if you have any questions as you go along.

@aintoha
Copy link

aintoha commented Apr 10, 2020

So the functions should be as standard R function?

Just to confirm, for storage, all the L2norms for pdf of every distribution should be in Pdf2Norm.R?And same goes for Cdf2Norm? That means, I should not separate for different distribution?

@RaphaelS1
Copy link
Collaborator Author

RaphaelS1 commented Apr 10, 2020

Yes and yes

@fkiraly
Copy link

fkiraly commented Apr 17, 2020

Question: if we add these as functions until the decorator is written, how should the dependency on the parameters be handled (as the methods will temporarily live outside an R6 class)?

Should these just be arguments?

For example, if we want to add the pdf2norm of the Gaussian, should this be a loose function with signature Pdf2Norm.Normal(mean,var), i.e., with two arguments, mean, var, or should this be a function with signature Pdf2Norm.Normal(), i.e., with no arguments that accesses mean, var in the environment it sits in?

@fkiraly
Copy link

fkiraly commented Apr 17, 2020

based one phone discussion right now: since the function needs to call self, the signature should be Pdf2Norm.Normal(self) where the argument is called self and expects a (constructed) distr object of the right type with set parameters. That way, later calls to self from within the class follow the same syntax, and the method can be added to the decorator by simply removing the argument.

For functions with additional arguments, you have, for example,
CdfInt.Normal(x,self), which later becomes CdfInt.Normal(x).

@RaphaelS1
Copy link
Collaborator Author

Sorry I didn't see this sooner Franz. After discussion with Ain it transpires that this is vastly simpler than what I initially thought and these can be added directly to the squared2Norm method in each Kernel but with an argument to control the shift

@fkiraly
Copy link

fkiraly commented Jun 12, 2020

It would still have to be done somewhere, no?
And we sould still need it for the distributions, not just for kernels.

Though using the kernel version for the distribution may simplify things.

On a minor note, I would call the methods something more descriptive like pdfSquared2Norm or pdfShiftedInnerProduct.

@RaphaelS1
Copy link
Collaborator Author

Though using the kernel version for the distribution may simplify things.

Exactly

On a minor note, I would call the methods something more descriptive like pdfSquared2Norm or pdfShiftedInnerProduct.

I agree and had been thinking something similar

@RaphaelS1
Copy link
Collaborator Author

Closing as now being implemented as methods and not decorators

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

3 participants