So Desmos released a whole suite of new, super exciting statistics features on the graphing calculator and you're trying to think of the best ways to implement them into your next activity.

Statistics teachers: this thread is for you beautiful people. Tune in. pic.twitter.com/ROEoX7QqXA

— Desmos.com (@Desmos) February 6, 2019

You

*could*open a graph screen and let students explore on their own, but then why make the effort to make it in activity builder? You*could*preload a dot plot, histogram, etc. into a half screen graph display and use CL to link in some data for students to enter, no harm in that, but don't you want to make full use of the ability to represent large amounts of data nicely and neatly?## Use the aggregate function to collect student data from the entire class and display it on each student's computer.

Believe it or not, this can be done with

We can use any input to take a a number and put it into a graph display.

**one line of code**in a graph component's CL script, but before we can get into it I'd like to take a quick look at how we can manipulate numbers in Desmos. This will just be a quick look into numbers and number lists so anyone with the know-how should feel free to skip ahead.We can use any input to take a a number and put it into a graph display.

Here, I used firstDefinedValue to make sure that a dot appeared even when nothing was entered

but you can do it just as easily by making the number whatever is typed into the math input.

We can also represent numbers in lists, and its actually these lists that we use to build stuff with the new stats features:

We can make a number list with CL just like we did a number:

Again, some fancy extra stuff here to make sure your window bounds fit all of your data, but essentially it boils down to this:

Essentially, we ask CL to create a list and then build the scatter plot as if the list was built. When we run the activity, these two parts work together with the CL script providing the list and the graph component building the dot plot from the list.

## Ok, on to aggregation

We said earlier that the way to build any of the new stats features is with a list. Wouldn't it be great if there were a function that did just that with numbers that students input? For that we have the aggregate function:

Ignore the red line here, he's cranky because he's incomplete. To complete this guy I need to put a number into aggregation. This can be any number thats a part of of an activity, not just a student input. If you've ever wondered how we do the "you have the highest score"/"at least one person has a higher score than you" display in activities like Point Collector: Lines, it uses aggregation. Here's how you complete it:

So we've taken numbers from each student and aggregated it, now it's time to make it into something. Our stats tools require a list so let's finish this up:

This is essentially what aggregate does. It takes a number from each student and turns it into a list that we can use to make stuff. With this single line of CL we can take the inputs from different students and build a plot of class data.

## What about bivariate data?

Bivariate data, e.g. scatter plots can be a little tricky to aggregate. Sure, we can make a list for each variable and plot the points using the two lists separately but depending on what type of input you're using you may run into trouble with x-values not matching their corresponding y-values. This is because of the way the data is gathered. In short, if you have students entering numbers one at a time, the computation layer will collect the information as it comes in. Therefore, if students enter coordinates out of order the x and y coordinates won't line up.

The best way to work around this is to use a formula in the graph display to combine the two inputs, aggregate that combined value, and then use another formula to deconstruct the two coordinates. Unfortunately, there isn't a single formula that you can use in all cases and the method you choose will depend on the possible values that students will enter, mainly the number of digits and the number of decimal places. These methods vary but I've included an example that works for integral values between 0 and 99. You can try it out as a student below (aggregation requires a class to pull the data from), but feel free to smash the copy and edit button here.

Note: ignore the CL script here, I added some extra precautions so that I can run this code without supervision. What you really want to look at is the expression list in the graph.

The best way to work around this is to use a formula in the graph display to combine the two inputs, aggregate that combined value, and then use another formula to deconstruct the two coordinates. Unfortunately, there isn't a single formula that you can use in all cases and the method you choose will depend on the possible values that students will enter, mainly the number of digits and the number of decimal places. These methods vary but I've included an example that works for integral values between 0 and 99. You can try it out as a student below (aggregation requires a class to pull the data from), but feel free to smash the copy and edit button here.

Note: ignore the CL script here, I added some extra precautions so that I can run this code without supervision. What you really want to look at is the expression list in the graph.

## Resources:

Last week I hosted a webinar with Desmos on this exact topic. Feel free to watch here:

https://cl.desmos.com/t/introduction-to-the-computation-layer-webinar-3/393

Here's the link again to the activity running throughout this post:

https://teacher.desmos.com/activitybuilder/custom/5c6a417407008410bf2144a2

As always, feel free to email ortweet me your questions or requests for clarification. Happy building!

https://cl.desmos.com/t/introduction-to-the-computation-layer-webinar-3/393

Here's the link again to the activity running throughout this post:

https://teacher.desmos.com/activitybuilder/custom/5c6a417407008410bf2144a2

As always, feel free to email ortweet me your questions or requests for clarification. Happy building!