Linear Regression proof of concept #123
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
Thanks for all your work on the
cetz
and related project, I love it!For my past work, I have been experimenting with linear regression plotting.
Herein, I want to propose to you a proof of concept:
The
x
marks plot a simulated measurement error (see utility function in my example).The dashed trend line is automatically fitted by
cetz-plot
for least square error.(The fourth example is simply random data where I attempt to fit a sine function.)
With this PR you find the code that I used for this proof of concept.
The main implementation challenge is that this needs some matrix operations (transpose, inverse, multiply). I don't think they are builtin to
typst
and neither is there a package for these.Therefore, I have added a very basic implementation using the Gaussian algorithm.
In a real application, I think this would rather be done using wasm, as this implementation already exceeds 1 sec of compilation time on my machine...
With these matrix operations available, the rest is pretty straight-forward.
Let me know whether you would be interested in this feature for
cetz-plot
and I will continue working on this code, write docs and tests etc.!