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

Improve plotter output, introduce randomness #135

Merged
merged 4 commits into from
Jan 21, 2024

Conversation

stevenpetryk
Copy link
Owner

@stevenpetryk stevenpetryk commented Jan 21, 2024

This improves the sample function central to Mafs' plotter.

Bug fix: duplicate points, incorrect subdivision

First, it corrects a bug that was causing duplicate points to be evaluated. For example, when sampling the domain [-16, 16] with sampling depth 4, these points were being generated:

[-16,-15,-13,-12,-12,-11,-9,-8,-8,-7,-5,-4,-4,-3,-1,0,0,1,3,4,4,5,7,8,8,9,11,12,12,13,15,16]

Of course, duplicates make no sense here, and we would actually expect a uniform distribution between -16 and 16. Also, we would expect depth 5 to produce 32 segments (33 points), not depth 4. So that was fixed by, thankfully, removing code.

Randomness

Additionally, for quite some time, I have been wanting to introduce some stable randomness to the sampling function, in a way that prevents the function from changing with every render. I finally decided to research that and introduce a pseudo-random hash function when evaluating the midpoint of the domain. This also required the midpoint function in sample to become a lerp, since we can no longer simply measure against the midpoint to compute errors.

Copy link

vercel bot commented Jan 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mafs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2024 7:45pm

@stevenpetryk stevenpetryk marked this pull request as ready for review January 21, 2024 19:29
@stevenpetryk stevenpetryk merged commit 2a0fbde into main Jan 21, 2024
7 checks passed
@stevenpetryk stevenpetryk deleted the unique-random-plotting branch January 21, 2024 19:53
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.

1 participant