Skip to content

Squared sinc distribution to create triangular kernel shape #151

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

Merged

Conversation

scken
Copy link
Contributor

@scken scken commented Jul 17, 2023

@mikeheddes, I added another sampling distribution to the FPE example script from @denkle.

It is a custom torch distribution that samples from a squared sinc function to get a triangular kernel shape in FPE.
This might be a helpful suggestion for other users because a linear kernel adds another useful one to the sinc and Gaussian shape.

I'm not sure if the implementation is the best to sample from the given distribution (rejection sampling) - maybe you have another idea for a better implementation.

@mikeheddes
Copy link
Member

@scken thank you for adding this example, it is very helpful indeed! I am not sure how to sample more efficiently, my first thought was to do inverse transform sampling but that doesn't seem to be simple in this case since the sinc doesn't have a nice inverse. We can always improve in a future PR if someone knows about a better way.

Just some minor comments on the code, could you change the comment ## Gaussian kernel at the top of the cells you added to reflect the actually implemented kernel. And the first figure label is "Triangular kernel with HRR model" which I belief should be "Triangular kernel with FHRR model". I also see that you got an error in the 2D kernels Unknown projection '3d', if you could resolve the error and re-run the cells that would be great, otherwise everybody will see the error.

Other than that I think the code is great and ready to be merged.
Thanks again!

@scken
Copy link
Contributor Author

scken commented Jul 18, 2023

Thanks @mikeheddes for your comments. I have fixed the points and pushed the changes to the branch.

@mikeheddes
Copy link
Member

Looks great @scken, thank you for your contribution!

@mikeheddes mikeheddes merged commit f6fdce8 into hyperdimensional-computing:main Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants