Note that there are some explanatory texts on larger screens.

plurals
  1. POHow-to: Find a good mathematical algorithm to distribute measuring points over time?
    primarykey
    data
    text
    <p>I'm currently implementing a software that measures certain values over time. The user may choose to measure the value 100 times over a duration of 28 days. (Just to give an example)</p> <p>Linear distribution is not a problem, but I am currently trying to get a logarithmical distribution of the points over the time span. </p> <p>The straight-forward implementation would be to iterate over the points and thus I'll need an exponential function. (I've gotten this far!)</p> <p>My current algorithm (C#) is as follows:</p> <pre><code>long tRelativeLocation = 0; double tValue; double tBase = PhaseTimeSpan.Ticks; int tLastPointMinute = 0; TimeSpan tSpan; for (int i = 0; i &lt; NumberOfPoints; i++) { tValue = Math.Log(i + 1, NumberOfPoints); tValue = Math.Pow(tBase, tValue); tRelativeLocation = (long)tValue; tSpan = new TimeSpan(tRelativeLocation); tCurrentPoint = new DefaultMeasuringPointTemplate(tRelativeLocation); tPoints.Add(tCurrentPoint); } </code></pre> <p>this gives me a rather "good" result for 28 days and 100 points.<br> The first 11 points are all at 0 seconds,<br> 12th point at 1 sec,<br> 20th at 50 sec,<br> 50th at 390 min,<br> 95th at 28605 mins<br> 99 th at 37697 mins (which makes 43 hours to the last point)</p> <p>My question is: Does anybody out there have a good idea how to get the first 20-30 points further apart from each other, maybe getting the last 20-30 a bit closer together?</p> <p>I understand that I will eventually have to add some algorithm that sets the first points apart by at least one minute or so, because I won't be able to get that kind of behaviour into a strictly mathematical algorithm. </p> <p>Something like this:</p> <pre><code>if (((int)tSpan.TotalMinutes) &lt;= tLastPointMinute) { tSpan = new TimeSpan((tLastPointMinute +1) * 600000000L); tRelativeLocation = tSpan.Ticks; tLastPointMinute = (int)tSpan.TotalMinutes; } </code></pre> <p>However, I'd like to get a slightly better distribution overall. </p> <p>Any cool ideas from you math cracks out there would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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