Line of best fit from Aggregate Table

My students are completing the Vroom Car Task.

I want them to compile their data. I have the graph set to show all of the students data, but on the next screen I want desmos to take all the points and draw a line of best fit with the slope & y-intercept identified.

I have two different methods, but neither is compiling the data to draw an accurate line of best fit.

I don’t see anything wrong… maybe because I’ve never tried creating a Line Of Best Fit in Desmos, but everything seems accurate and correct (especially your formula for the LOBF)

Have you tried it with multiple fake students? You can see in the graph if you reduce lists X and Y to a single element r_1 is undefined due to the 0 denominator, but as soon as you add a second element it will have a defined value.

Side question: Is it your intent to only use the first entry of each student for the line of best fit? You can join your aggregate lists in the CL (or graph, but that will slow your graph down a little more).

H1 = aggregate(table11.cellNumericValue(1,1))
H2 = aggregate(table11.cellNumericValue(2,1))
H3 = aggregate(table11.cellNumericValue(3,1))
H4 = aggregate(table11.cellNumericValue(4,1))
joinedH = H1.join(H2).join(H3).join(H4)

numberList(`H_{join}`): joinedH

You can use the .lastValue() as you’ve used elsewhere if that’s your preference. I do think you’ll want to only enable your table button when it’s filled though, because if a student leaves a cell blank somewhere in the middle, then the coordinates get misaligned and throw off your data.

t = table11
contentList = [
   t.cellNumericValue(1,1),
   t.cellNumericValue(2,1),
   t.cellNumericValue(3,1),
   t.cellNumericValue(4,1),
   t.cellNumericValue(1,2),
   t.cellNumericValue(2,2),
   t.cellNumericValue(3,2),
   t.cellNumericValue(4,2)
]
disabled: contentList.any((el) => isUndefined(el))
1 Like

I suspect Desmos isn’t able to consistently grab the correct x’s and y’s from an aggregate, essentially pairing up sets of x’s and y’s that aren’t really pairs at all, but do come from somewhere in the aggregate function. Down to a timing issue or registering the aggregate function I believe, since I’ve seen aggregate delay times of upwards of 30 seconds in some instances.

I posted about this here a while back: Aggregation Plot Errors

1 Like

But won’t that just disable the whole table for the student if that have one empty cell?

I may have been unclear. That CL is for the button, but is pulling information from the table.

Ohh!!! I see… that makes more sense if it’s for the button.

A followup here. I brought this up with some engineers I know work with the aggregate function. They said that any misalignments are likely the result of incomplete entries. One way to avoid this is to use a placeholder value. I believe what you (@Mike_Gleeson ) were attempting to do was have an NaN value to basically exclude that point. (Are those also excluded from best fit calculations?) However, the way you coded it would only exclude the current student’s point from their graph, but it would still collect (without the undefined value) for the aggregate lists; thus misaligning the lists. I’ll post detail and a fix in your prior post.