Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I understood correctly what you're asking (and that is somewhat doubtful), you should find what you seek in these links:<br> <em><a href="http://en.wikipedia.org/wiki/Linear_interpolation" rel="nofollow noreferrer">Linear interpolation</a> (calculating the value of the point in between)<br> <a href="http://en.wikipedia.org/wiki/Trapezoidal_rule" rel="nofollow noreferrer">Trapezoidal rule</a> (calculating the area below the "curve")</em></p> <hr> <p>*****Edit, so we can get this over :) without much ado:*****</p> <p><strong><em>So I have graph made in flot that shows the network usage (in bytes/sec) for the user. The data is 4 minutes apart when there is activity, and otherwise set at the start of the usage range (let's say day 1) and the end of the range (day 7). The data is coming from a CGI script I have no control over, so I'm fairly limited in what I can provide the user.</em></strong></p> <p>What is a "flot" ?</p> <p>Okey, so you have speed on y axis [in bytes/sec]; and time on x axis in [sec], right? That means, that if you're flotting (I'm bored, yes :) speed over time, in linear segments, interpolating at some particular point in time you'll get speed at that particular point in time. If you wish to calculate how much bandwidth you've spend, you need to determine the area beneath that curve. The area from point "a" to point "b" will determine the spended bandwidth in [bytes] in that time period.</p> <p><strong><em>It took me weeks to finally get a helpful math person to explain this to me. Everyone else has insisted on trying to teach me Riemann sum techniques and all sorts of other heavy stuff that not only is confusing to me, doesn't seem necessary for the problem.</em></strong></p> <p>In the immortal words of Snoopy: "Good grief !"</p> <p><strong><em>But I also want the user to be able to highlight the graph from two arbitrary points on the y-axis (time) to get the amount of network usage total during that range. I know this would be inaccurate, but I need it to be the right inaccurate using a solid equation.</em></strong></p> <p>It would not be inaccurate. It would be actually perfectly accurate (well, apart from roundoff error in bytes :), since you're using linear interpolation on linear segments.</p> <p><strong><em>I thought this was the area under the line, but experiments with much simpler graphs makes this seem just far too high. I figured out I could take the distance from y2 - y1 and multiply it by x2 - x1 and then divide by two to get the area of the graph below the line like a triangle, but again, the numbers seemed to high. (maybe they are just big numbers and I don't get this math stuff at all).</em></strong></p> <p>"like a triangle" --> should be "like a trapezoid"</p> <p>If you do deltax*(y2-y1)/2 you will get the area, yes (this works only for linear segments). This is the basis principle of trapezoidal rule.</p> <hr> <p>If you're uncertain about what you're calculating use dimensional analysis: speed is in bytes/sec, time is in sec, bandwidth is in bytes. Multiplying speed*time=bandwidth, and so on.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload