Posts Tagged ‘desmos’

Linear Regression by the Median of Slopes

May 19, 2013 Leave a comment

I have been trying to come up with a lesson about linear regression that involves more than pushing a few buttons, like on the TI-8ish, or using sliders in Desmos.  I tried to search the web for lessons of other people but I could not find what I was looking for.  Then I came across a method of finding the line of best fit called Theil–Sen estimator.  Here is the method.

As defined by Theil (1950), the Theil–Sen estimator of a set of two-dimensional points (xi,yi) is the median m of the slopes(yj − yi)/(xj − xi) determined by all pairs of sample points. Sen (1968) extended this definition to handle the case in which two samples have the same x-coordinate. In Sen’s definition, one takes the median of the slopes defined only from pairs of points having distinct x-coordinates.

Once the slope m has been determined, one may determine a line through the sample points by setting the y-intercept b to be the median of the values yi − mxi.[8] As Sen observed, this estimator is the value that makes the Kendall tau rank correlation coefficient comparing the sample data values yi with their estimated values mxi + b become approximately zero.

I really like this idea because it reinforces a lot of procedures of linear equations.  Here is how I might do the lesson. A link to the entire Desmos graph is here.

First give the students data and have them plot it with Desmos. This data is the annual gross ticket sales (in 100’s of millions) where x=0 for 1995. Using the table feature in Desmos is great.

Ticket Sales (100’s millions) VS Years (x=0 for 1995)

Next I would have students find the First Order Differences and plot these on the same graph.  We would have a discussion about what these values mean and also talk about how these are approximately constant so a linear model would be a good fit.

Green dots are the first order differences

Next we would begin finding the median slopes.  We might begin by asking how many different slopes could be found between 17 points.  Obviously, we would not find them all so we would assign a certain amount for each student to find.  Then we would gather up all of those slopes and plot them in Desmos.  This should be a great visual example to see the outliers of slopes within the data.  (For this example, I only found 10 different slopes.  Also, note that the first oder differences could be used as slope values.  Those slope values are for consecutive points.)

10 different slopes found within the data.

Then we can discuss what “average”, (mean, median, mode, midrange), we should use to find the “average slope”.  In Desmos, finding the median slope is easy.  Click on the top line, then hide it. Click on the bottom line, then hide it. Click on the new top line, hide it. Click on the new bottom line then hide it.  Continue doing so and this will result in the median slope.  Here is a picture of the final two.

The two median slopes out of the ten.

We can also plot that median slope with the first order differences.  This could bring up a good discussion about do we really need to find other slopes or could we just use the first order differences to find the “median slope”

Plotting the line y=median slope with the 1st order differences

Next we can go back to the table and find the median y-intercept.  In the Desmos table, we will make a column of values that is the expression y-(median slope)x.  We can also plot those points to show what the y-intercept would be for each data point.  Here is that graph.

Purple dots are the y-intercepts based on the median slope and data point.

Now that we have all of those different y-intercepts we can use a slider to estimate the median y-intercept value.  We could also throw the values into a spread sheet if we wanted, but I think the slider will be good enough. I made the slider have a lower bound of 4 and an upper bound of 5.  The b value ended up being 4.554.

Using a slider value to estimate the median y-intercept.

Finally, we are ready to plot the line of “median fit.”  using the equation y = (median slope)x + (median y-int)

The end result: Line of Median Fit.

For only using ten different slopes, I would say that the line looks pretty good.  However, the data did a have a strong correlation to begin with.  I have not compared the “median line” to line of least-squares because I think that would be a good follow up.  I think this method goes into the heart of regression.  Students get to see how many different lines are used to find the best line.  Student review stats concepts and how outliers impact different averages.  Students are creating a lot of evidence for their model, instead  of just relying on the “r-value”.

One other thought would be to have student’s create an error region for the model.  This might help them understand ideas of interpolation and extrapolation. Plus, it might allow us to discuss standard deviation, too.  In the graph below I graphed {median slope(x) + 1.15(median y-int)} and {median slope(x) – 1.15(median y-int)} to create a 15% above and 15% region. I could have found the standard deviation of the median b value and done three standard deviations above and below.

15% above and 15% below the median line.

The more I explore this concept the more it seems like it turning more into a statistical analysis.  I need to determine if that is the route I want to go on since the class I am developing this for is “Math Modeling” course.

I hope all of this gives you some ideas about linear regression.  I have not designed the lab sheet that will go with this yet.  I would love to hear feed back if you have any.

Your Homework: Play Temple Run

May 16, 2013 Leave a comment

Summer is here. Yippee for me!  This means that I can get back to blogging some of ideas.  So, here is my next idea, The Math of Temple Run.

Have your ever played Temple Run?  Probably, yes, given the game’s popularity.  If not, here is information about the game.  The game is free to play. Did you catch that – FREE! But what is better than being free is that Temple Run has a lot math problems waiting to be explored.  Here are some that I will be trying out.

  • How fast is the person running?  The game keeps track of how far you run in meters.  This means that you can time how long the person runs and then calculate the speed.
  • Is the person’s speed possible?  I won’t spoil it for you but you need to see how fast the person runs.
  • The person runs faster as the game progresses.  Students can make a chart of distance and time because the game flashes up the distances as you travel.  Does the increase of speed follow a quadratic pattern or is it more like a piece-wise linear?
  • Next have students play the game and record 15 rounds of data.  Here is a link to the table of data that I made.

    Blue Dots: Coins vs Distance – Red Dots: Distance vs Score

    The data looks to have a strong linear correlation, which allows us to explore rates of change.  What does the rate of change mean for the blue dots and what does the rate of change mean for the red dots?  Are certain games better than others?  Is a better game based on the distance? Is a better game based on the amount of coins? Is a better game related to the number of coins compared to the score?

  • In Desmos we can use a slider to create a line of best fit.  The  ones I made were y=(coins/dist)x and y=(score/dist)x  I will probably discuss with students why we can make the initial value of zero.  (Actually, one of the goals in the game is to go 1,000 meters and get zero coins.)  Next, with the slider values we can either make the numerator or denominator equal to 1 and adjust the other slider accordingly. Once they have the line of best fit, we can talk about what it means for the data points to be above/below the line of best fit.
  • Remember that each student will be playing the game, hopefully.  So, this means we will have many different graphs.  This will allows us to talk about how you can look at a graph and say, “That is good player. This is a so-so player. Etc.” or to be able to look at graph and point out who has had more experience playing the game.
  • How is the score calculated?  After students record the amount of coins, distance, and score they will have some data to try and figure out how the score is calculated.  The game does not tell how the score is calculated.  All you see is a running total in the upper right corner.  Wikipedia does give a formula for the score. However, that formula was not working for me.  I might doing some type of error.  But this is good because it gives students the opportunity to figure it out.  Plus, the formula opens up the door to the floor function and ordinal numbers.
  • I might throw in Game Theory at the end.  Not quite sure.

Plenty of stuff to work on there.  I have not made the worksheets yet but I will update the post soon.  If you could, please play the game 15 times and record your data into this Desmos graph  Save your work and then post it here in the comments or on twitter @LukeSelfwalker.  I will gather up the data and post it later.  Thanks for your help.

My New Part-time Dream Job

January 17, 2013 Leave a comment

I really don’t know how else to put this – I am now part of Team Desmos!  For now, most of my time is spent running the Desmos twitter feed.  I remember three months ago, a person asked me, “Luke, what would be your dream job?” I responded, “To teach at a community college and to work for Desmos.”  Now, all of the sudden, poof, it happened. But how did a community college instructor who lives on the opposite coast from where Desmos is located get this chance of a lifetime?  Good question.  The following post gives a short description of how all of this happened.

I first came across the Desmos calculator back in late 2011.  Honestly, the first attraction that hooked me in was the price, which was free.  So, I began messing around with it and I quickly saw how easy it was to use.  If I had a question, Eli, who is the CEO, would respond to my emails.  (I remember thinking how cool it was that the CEO of the product I was using was helping me.)  Then as I used Desmos in the classroom, by using an overhead projector, I saw how much more my students were engaged.  Also, Desmos allowed us to explore math concepts in a way I could have not done earlier.  The combination of customer service and student enjoyment motivated me to see just how many different ways could I apply Desmos to my teaching.

Some graphs I made were art. Some graphs I made were math demonstrations.  Some graphs were for my own enjoyment. So, yeah, no need to hide from the truth, Desmos became one of my hobbies.  A collection of my graphs can be seen here.  When ever I finished  a graph, I would share it on Twitter.  Once in awhile an educator would respond and most of the time Desmos would give a RT (retweet).  This gave me nice warm math fuzzies.  I love to share math and  knowing that people across the world were seeing my math influenced me to begin promoting Desmos when ever I could.

I did three different presentations (NCCTM, NCMATYC, and SOCOMATYC) and all of them had a bit of Desmos with the topic I was discussing.  Each time I would ask the audience if they had heard of Desmos and only a few hands would go up.  Then as I would introduce them to the slider feature, the choice of colors, the projector mode, and so on, each one would be amazed.  The look on their faces reminded me when I first began.

Another place I was sharing Desmos work was on a facebook page .  I run a facebook page  for the students at the school I work.  Like I said, I like to share and talk about math and this is just another venue.  So, on this page I would post Desmos graphs that my students would create and Desmos would see and share them as well.  Students loved to showcase their work and I loved to share it.

Overall, the main theme in my story is sharing math.  Social media removes the physical distance and makes sharing easy.  Sharing is a common part of life and Desmos has integrated that into their calculator.  I was able to share my graphs with two clicks, copying and pasting a URL.  Students can do the same and, even better, they want to.  Also, students can print out their graph and share a hard copy, too. They did this once to make a coloring book for Kindergartners.  And, yes, I print mine out, too, and I have them hanging in my office.  So, just how did I get to join Desmos? I would say by sharing what I love to do.  I know there are thousands of people who do the same and that is why I feel so lucky to have been chosen.

Categories: desmos Tags: ,

Desmos and LaTex Mashup

December 28, 2012 Leave a comment

Over the past year, I have  created a lot of graphs in Desmos.  A collection of these can found here.  There you will find a wide range of graphs; some  are art related and some are only using sliders.  Also, some of the graphs are lab based and explorations.  These graphs have instructions for students to follow and some blank spots for their answers.  However, I have wanted students to work on paper, too, while working in Desmos.  So, I am now creating a Desmos Lab packet.  This lab packet will look very similar to the Desmos graph, allowing students to work through Desmos and record their work on paper.  Here are the steps if you would also like to create a worksheet/lab for students to follow.

  1. Go to this website. The directions are in the lower right hand corner.  All you have to do is drag “Equations List” to your bookmarks bar.  Then, “From a Desmos Graph, it will open a new window containing text and latex for the expressions from the expressions list.”
  2. Now create a lab or some type of exploration in Desmos.  When done click the “Equations List” and you will see all of the inputs from you Desmos graph that can be copied in LaTex.
  3. Finally, polish up your LaTex file.  Now your students have a piece of paper that they can easily follow along with the Desmos graph.

There you go simple as that!  I am excited to try this out with my students.  Here is a link to what my looks like so far. Check it out and let me know if you have any ideas.

Here are is an example of those steps.

  • The Desmos graph is here:
  • The input after pressing Equations list looks like this.  I copy it and paste it into a LaTex document
    Semi Circle with radius 'a'.
    Below are two points on the semi-circle, such that the line connecting the two is parallel to the x-axis and is a factor 'b' of the diameter. 
    $\left(ba,\space f\left(ba\right)\right),\space\left(-ba,\space f\left(-ab\right)\right)$
    A factor "b" of the diameter. For example, b=0.5 means that the top blue line half of the diameter. b=0.2 would be two tenths of the diameter, or in other words, one-fifth.
    Begin by letting a=2 and b=0.5.  What is the height between the two blue lines?
    Next let a=4 and b=0.5. What is the height between the two blue lines?
    Try more 'a' and 'b' values till you see a pattern.  See if you can write the height as function of b. 
    Your answer above probably has some trig functions involved.  See if you can write the equivalent algebraic expression.
    The equivalent algebraic expression
    $\left(b,\space H_{eight}\left(b\right)\right)$
    Graphs of the two blue lines.
    $y=\left\{-ab\le x\le ab:f\left(ab\right)\right\}$
    $y=\left\{-a\le x\le a:0\right\}$
Categories: blah-blah, desmos Tags: , ,

What is tangent?

November 25, 2012 Leave a comment

Trig functions have a lot of acronyms. Is this good or bad, well I don’t know. What I do know is this: tangent is much more than just sine over cosine or opposite over adjacent. However, the text books I teach from usually focus on that. So, I thought I would make an investigation that allows students to see that tangent can also be seen as length of the tangent line to the unit circle at (0,1) Wikipedia gives some good pictures. Click here to see the article.

Note the location of tangent and secant

I also like in the article when it writes about “Slope Definitions”.

“Tangent combines the rise and run” meaning that Tangent takes the angle of the line segment and tells its slope; or alternatively, tells the vertical rise when the line segment’s horizontal run is 1.

So, next time you talk about the trig functions be sure to expand on the idea of tangent. Here is a Desmos graph I made that you can use. Click on the image to see the graph.

Categories: desmos Tags: , ,