{"id":7465,"date":"2012-07-21T08:39:43","date_gmt":"2012-07-21T00:39:43","guid":{"rendered":"http:\/\/www.intmath.com\/blog\/?p=7465"},"modified":"2012-07-24T20:59:44","modified_gmt":"2012-07-24T12:59:44","slug":"constrained-data-model-can-you-solve-it","status":"publish","type":"post","link":"https:\/\/www.intmath.com\/blog\/mathematics\/constrained-data-model-can-you-solve-it-7465","title":{"rendered":"Constrained data model - can you solve it?"},"content":{"rendered":"<p><\/p>\n<h2>Constrained data model - can you solve it? <\/h2>\n<p>Statisticians are often asked to predict the future. Their job is to look at historical trends and to make their best guess what will happen tomorrow, or maybe next year. This involves a process  called <strong>extrapolation<\/strong>, where we project into the future based on past data.<\/p>\n<p>For example, here is a set of data representing company sales (variable <em>s<\/em>) for a period of 10  days (<em>t<\/em>):<\/p>\n<table class=\"postTable\">\n<tr>\n<th scope=\"row\"><em>t<\/em><\/th>\n<td>1<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<td>4<\/td>\n<td>5<\/td>\n<td>6<\/td>\n<td>7<\/td>\n<td>8<\/td>\n<td>9<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<th scope=\"row\"><em>s<\/em><\/th>\n<td>2<\/td>\n<td>4<\/td>\n<td>3<\/td>\n<td>5<\/td>\n<td>9<\/td>\n<td>6<\/td>\n<td>8<\/td>\n<td>9<\/td>\n<td>8<\/td>\n<td>10<\/td>\n<\/tr>\n<\/table>\n<p>Let's graph the data to get a better idea what it looks like:<\/p>\n<p><img src=\"\/blog\/wp-content\/images\/2012\/07\/data-1.png\" alt=\"data curve\" \/><\/p>\n<p>To extrapolate intelligently, we need to consider the <strong>shape<\/strong> of the data curve, and then fit a curve as best we can through the points.<\/p>\n<p>At the beginning, there is a steep rise in sales, but  then it flattens out (perhaps the salespeople were getting tired). It appears to be a <a href=\"\/exponential-logarithmic-functions\/2-graphs-exp-log-fns.php\">logarithmic curve<\/a>, which in its standard form, starts fairly steeply, and then flattens out. <\/p>\n<p>There are various <a href=\"https:\/\/www.intmath.com\/exponential-logarithmic-functions\/dow-jones-industrial-ave-graph.php\">formulas for fitting a curve to data<\/a> (see the bottom of the page), but we'll use software. <\/p>\n<p>We'll get Excel to draw a curve through the data points and then extrapolate for us. After entering the data in Excel, we highlight it, then choose the &quot;<strong>XY(Scatter)<\/strong>&quot; option. Once we see the chart, we select the graph and right click, then choose &quot;<strong>Add trendline<\/strong>&quot;. We choose &quot;<strong>logarithmic<\/strong>&quot; because that's the shape of our data curve. Under &quot;<strong>Options<\/strong>&quot;, we can choose to &quot;<strong>Forecast<\/strong>&quot; by as many steps as we like. <\/p>\n<p>So in this next graph, you'll see the logarithmic growth model passing through the given data. I've forecast the next 20 days, so we can get an idea how our sales team will perform for the rest of the month, assuming their historical performance (for the first 10 days) continues. <\/p>\n<p><img loading=\"lazy\" src=\"\/blog\/wp-content\/images\/2012\/07\/data-3.png\" alt=\"data curve\" width=\"460\" height=\"300\" \/><\/p>\n<p>(The above set of data and curve is just to illustrate the problem. We need a formula that will work with <b>any<\/b> set of data, within the constraint mentioned next.)<\/p>\n<p><strong>Constraint<\/strong><\/p>\n<p>Now, (and here's where the challenge comes) say we need to produce a curve such that the sum of the values of the model curve is <strong>exactly<\/strong> the same as the sum of the values (for the first 10 days) in the original data set?<\/p>\n<p>For example, here is the data again, but with a new row (<em>m<\/em>) containing values that fit the above constraint. That is, the sum of the first 10 sales values (variable <em>s<\/em>) is the same as the sum of the first 10 model values (using variable <em>m<\/em>). <\/p>\n<table class=\"postTable\">\n<tr>\n<th scope=\"row\"><em>t<\/em><\/th>\n<td>1<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<td>4<\/td>\n<td>5<\/td>\n<td>6<\/td>\n<td>7<\/td>\n<td>8<\/td>\n<td>9<\/td>\n<td>10<\/td>\n<td><strong><span style=\"font-family:'Times New Roman', Times, serif\">&Sigma;<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<th scope=\"row\"><em>s<\/em><\/th>\n<td>2<\/td>\n<td>4<\/td>\n<td>3<\/td>\n<td>5<\/td>\n<td>9<\/td>\n<td>6<\/td>\n<td>8<\/td>\n<td>9<\/td>\n<td>8<\/td>\n<td>10<\/td>\n<td><strong>64<\/strong><\/td>\n<\/tr>\n<tr>\n<th scope=\"row\"><em>m<\/em><\/th>\n<td>2.17<\/td>\n<td>3.53<\/td>\n<td>4.69<\/td>\n<td>5.68<\/td>\n<td>6.52<\/td>\n<td>7.23<\/td>\n<td>7.84<\/td>\n<td>8.36<\/td>\n<td>8.80<\/td>\n<td>9.18<\/td>\n<td><strong>64<\/strong><\/td>\n<\/tr>\n<\/table>\n<p>The <strong>sum<\/strong> (<strong><span style=\"font-family:'Times New Roman', Times, serif\">&Sigma;<\/span><\/strong>) is given in the final column. Both rows <em>s<\/em> and <em>m<\/em> add to 64. <\/p>\n<p>Here is the graph of the <em>m<\/em>-values given in the above table. You'll notice it is similar to the Excel logarithmic graph, but not exactly the same. I have once again extrapolated another 20 steps in the chart below. We observe using this constrained model that the sales per day at the end of the month is less (around 11.5) than Excel's logarithm curve (which gave almost 13). <\/p>\n<p><img loading=\"lazy\" src=\"\/blog\/wp-content\/images\/2012\/07\/data-2.png\" alt=\"data curve\" width=\"460\" height=\"300\" \/> <\/p>\n<p>So, your challenge is to develop a formula to produce a curve that goes through any set of data, given the above constraint. Good luck! (This is quite challenging, but give it a go.) <\/p>\n<p class=\"alt\">See the <a href=\"https:\/\/www.intmath.com\/blog\/mathematics\/constrained-data-model-can-you-solve-it-7465#comments\" id=\"comms\">10 Comments<\/a> below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/www.intmath.com\/blog\/mathematics\/constrained-data-model-can-you-solve-it-7465\"><img loading=\"lazy\" src=\"\/blog\/wp-content\/images\/2012\/07\/data-curve3_sm.png\" alt=\"data curve\" title=\"data curve\" width=\"128\" height=\"100\" class=\"imgRt\" \/><\/a>Can you fit a curve to given data with this constraint?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mo_disable_npp":""},"categories":[4],"tags":[134,127],"_links":{"self":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts\/7465"}],"collection":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/comments?post=7465"}],"version-history":[{"count":0,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/posts\/7465\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/media?parent=7465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/categories?post=7465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.intmath.com\/blog\/wp-json\/wp\/v2\/tags?post=7465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}