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

Support sampling normal distribution in expressions #362

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

msvbg
Copy link
Contributor

@msvbg msvbg commented Aug 8, 2024

Closes #353. I decided to look at this issue to build some familiarity with the code base. It mostly just copies what was done for the uniform distribution, with some minor tweaks.

I tested it by replacing various usages of uniform with normal in the examples, and it looked right to my eyes but I'm not sure how to test it more rigorously. I considered making a specialized example but that felt like overkill. Let me know what would pass the quality bar for you in terms of testing.

Copy link
Owner

@djeedai djeedai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Some minor improvement if you have time, would save a few instructions per sampling. Cheers

@msvbg
Copy link
Contributor Author

msvbg commented Aug 19, 2024

I don't fully understand this review comment, did you leave something out?

@djeedai
Copy link
Owner

djeedai commented Aug 19, 2024

Yes no surprise because GitHub didn't post my actual comment.

The sampling for vec2 (and others) is too much. Box-Muller can create 2 random normal vars from 2 uniform ones, so you don't need to sample 2 vec2 vars, only 1 is enough. That would save some instructions. Same for vec3 and vec4.

@msvbg
Copy link
Contributor Author

msvbg commented Aug 31, 2024

Hey, sorry for the slow turnaround on this. I pushed a fix just now

@djeedai
Copy link
Owner

djeedai commented Sep 1, 2024

@msvbg there's a linter error, but should be fine after that. Thanks!

@djeedai djeedai merged commit 1ad6298 into djeedai:main Sep 2, 2024
15 checks passed
@msvbg msvbg deleted the normal-distribution branch September 2, 2024 09:19
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.

feat: Add an expression for normal distribution
2 participants