Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: http://www.swissmicros.com/dm42/decoder/

Here is my linear regression graph plotting program, which gives gradients, intercepts and standard errors in both (correctly!). It uses a menu too, and the graph can be manipulated in a few ways: explained below.

To use, place a matrix on the X-register with dimensions Zx2, where Z is the number of data points. The left column of the matrix is the x-axis values and the right column of the matrix is the y-axis values.

On running the program GRAPH, you see this.

20180212-09073597.jpg (77.27 KiB) Viewed 462 times

On pressing PLOT , you see this (autoscaled).

20180212-09082753.jpg (12.92 KiB) Viewed 462 times

You can exit out of this by pressing a different menu button (not the F1 button, that just redraws the graph. Maybe I'll change that to a 'BACK' button in a later version) or pressing R/S.
The other buttons that show gradient, error in gradient, intercept and error in intercept all show the values on the screen using the current display settings (to be updated in a future version) and leave values on the stack if you EXIT out. Pressing the CHNGE allows some graph manupulation, such as SWAPX which swaps the X and Y axes around (and indicates such with the flag 1 being set), Z^? raises an axis to a power (2, 0.5, -1, whatever you like, first you give the power, then you choose the axis to affect) and CHNGE does some other change to a given axis, but needs a program called CHANGE with the change to implement.

The menu works pretty well, and I'm happy with the outcome so far. I just need to tweak the display settings - I want the program to choose 3-sigfig SCI notation for the gradients, intercepts and errors being displayed, then return to the previous settings when the program is EXITed. Shouldn't be too tricky to do at some time soon.

Please let me know what you think and what I need to do to improve it. If it's broken, let me know! Uses the default statistical registers, Flag 1, 2 and Flag 81.

Interesting. I've met this before. The differences for what we deal with in a high-school lab are small enough to be ignored. I wrote a [rather unsophisticated] Monte Carlo algorithm for Excel to get an alternative method of forming gradients, intercepts and their standard errors. It estimates errors around three times larger (or there abouts, does depend on the data, obviously), with values of gradient and intercept that lie well within the errors of each other (Monte Carlo compared against least squares). The way high schoolers have to estimate errors is mostly by eye, and high-school-endorsed estimates of errors tend to be even higher than the Monte Carlo estimates.

I share this guff with my A Level (ages 16-18) Physics students to help them justify to themselves why estimating errors by eye is acceptable. They often believe that physics, like mathematics, is pure and perfect. When they meet errors for the first time, they assume there's a 'correct' way to analyse them. Of course, every method produces estimates based on different assumptions. After meeting this idea, they're happier estimating errors using a less-rigorous method.

I wonder if I can program a Monte Carlo method into my DM-42 {he says, musing to himself}. It needs to randomly sample pairs of data points 20,000 times to produce a worthwhile estimate (~1% error in the error values). Might not have time to play with that until this summer.

The regression analysis program including preservation of user display state. I am sorry for the twistiest of spaghetti coding, I can write structured code but for some reason FOCAL just takes me right back to playing around with BASIC and bad habits return. Plus, not convinced FOCAL is that good for structured programming either.

As before, this program needs a matrix in the X-register when it is run, with Zx2 dimensions where Z is the number of data points. EXITing out of the program restores the previous display state.

Still chugging along with this. Now I have an 82240B I decided to add the ability to print results. The spaghetti code I'd written needed a lot of restructuring, which I've done now (update to follow when I've sorted the graph printing bit too), but...

IMG_20180311_172524~2.jpg (43.01 KiB) Viewed 225 times

The graph is there. Tiny, but there (just a dump of the graph on the screen with PRLCD in GrMod 0).

So, I'm open to ideas. How can I print graphics across the full width of the paper? My idea was to simply slice the graph into three or four horizontal slithers and print each sequentially, but I'm not convinced that'll look any good.

Some updates to the program structures (making better use of XEQ and RTN). The convention I've used is to have subroutines labeled with a . before the name.

If you want to try it out, put a matrix with data to plot in the X-register. The matrix should have two columns and as many rows as there are data points. The first column are the x-axis values, the second are the y-axis values.

I would run CUSTOMM first, which keeps a custom menu open, so that if you exit out you still see CLS, CONST, etc. The graphing program is called "GRAPH". If you wish to print the table, gradient, intercept and a teeny tiny graph, F4 is "PRINT" when the graph is visible on the screen. I've slipped a PSE in so that the menu can be briefly seen before the plot appears.