Error on mean calculation from random generator

I have this activity that I’ve used for a couple of years now but my students are getting an error on one slide. I’m attaching the slide for assistance. It appears that when the student checks their answer they will get an “incorrect” if the list is showing “undefined”. I’m not sure why it is showing “undefined”. The “?” are can be ignored and the student response is ok. It’s the “undefined” that is causing the problem.

Thank you,

A list defined by [1,6,…,max] can overshoot the upper limit - for example, if you do [1,6,…,20] it will give [1,6,11,16,21]. So the activity is sometimes looking for the 237th or 238th term of a 236-long list, hence the undefined.

You can ‘sanitise’ a list by having something like s_0 = s[s>0], which will create a new list s_0 that removes any undefined terms.

Thank you for getting back to me. I tried adding this as a line and I am still getting “undefined” in my random results and the mean as incorrect.

Similar to another thread regarding undefined terms, try s[0<s<infinity].

Have you changed all of the other lists to now look at s_0 rather than s? Remember s still has undefined terms in it.

Unfortunately, I do not understand a lot of the programing and I don’t understand " Have you changed all of the other lists to now look at s_0 rather than s ? Remember s still has undefined terms in it." because the only place I see “s” is line 4. I do not see it as part of any of the other statements. So I’m not sure what to do with: s_0 = s[s>0] or s[0<s<infinity]. Are these supposed to have their own command line in the “edit graph” or be part of other command lines or am I supposed to place these in the computation layer?

So at the moment, you have list s that picks every fifth value and sometimes looks for an item that doesn’t exist and therefore has an “undefined” at the end. This list is then used in the label of P (line 7) and the mean calculation on line 9. The mean can’t be defined if one of the terms in the list is undefined.

Daniel and I are suggesting you can sanitise this list by creating a new one, s_0 or whatever you want to call it, that picks only the defined elements from s. Now you have a “clean” list, it’s this that you need to use in lines 7 and 9, not the original s which still has the undefined term in it.

Does that make sense?

1 Like

Here’s a different way to index list L_1. I added L_index which is essentially a list of [1…5] repeated up to the length of L_1. Then, rather than using an arithmetic sequence beginning with L_0, I’m filtering L_1 using the list L_index where it is equivalent to L_0. No worries of undefined values… Desmos | Graphing Calculator

Thank you for explaining. I’m slowly learning the programing for the graphing calculator.

Thank you! I made the changes that you gave and it works!

You could also potentially replace the 5’s with a variable, if you wanted to change how you’re sampling.