My set-up is the following, I have two variables $N$ and $TTR$, and I have these points for each variable:

$N$ = [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]

$TTR$ = [0.818, 0.812, 0.812, 0.804, 0.804, 0.798, 0.792, 0.793, 0.788, 0.784, 0.781, 0.778, 0.776, 0.771, 0.767, 0.767]

I want to fit these data to the following model:

$$TTR=D/N \cdot \left( \sqrt{1 + 2N/D} - 1\right)$$

where $D$ is the parameter that I want to find and is gives the best fit.

Based on the example I am taking this, D = 66 should be around the "optimal" parameter, plotting these results I get:

enter image description here

I am trying a brute force approach, where I vary D from 1 to 70 (since D is "limited" to this set of values), and finding the D with the least mean squared error, however I get $D_{optimal} = 28$, and the result of that is shown in the following figure:

enter image description here

which is not better than the real optimal value, at least visually. How can I address this problem?

  • 1
    $\begingroup$ The blue line in the first plot does not correspond to the values of TTR that you are giving. $\endgroup$
    – AugSB
    Jan 18, 2016 at 17:32
  • $\begingroup$ Then your brute force algorithm must be wrong. When I do that in matlab I get something like 63.04... as optimal value (in the least squares sense) and this also visually very good (much better also as 66). $\endgroup$ Jan 18, 2016 at 17:40
  • $\begingroup$ It would be useful to give more details about what you are doing when trying a brute force approach and finding the D with the least mean squared error. Obviously, $D=28$ is not optimal. $\endgroup$
    – AugSB
    Jan 18, 2016 at 17:41
  • $\begingroup$ The blue line may vary, since is a mean value of 1000 runs, I forgot to mention that. However, the results that Elmar Zander make sense. How did you got that value? What I did was the following: Varied D from 1 to 70, then applied the formula for the N I had, and then compute mean squared error and pick the D which had the minimal value. $\endgroup$
    – dpalma
    Jan 18, 2016 at 17:54
  • $\begingroup$ Thanks to everyone, the way I was fitting the curve was obviously wrong. I did apply least square fitting and got a result very close to what Elmar found, thanks to everyone $\endgroup$
    – dpalma
    Jan 18, 2016 at 18:25

1 Answer 1


There are many ways of finding the optimal value. One is to express the value $D$, making a distribution $D=D(TTR,N)$ and then use some other technique of averaging. Basically you could take simply the average value but you can do a little bit better if you observe your data better.

You start: $TTR=\frac{D}{N}(\sqrt{1+\frac{2N}{D}}-1)$ and after some work you have $$D(TTR,N)=-\frac{TTR^2\cdot N}{2(TTR-1)}$$

If you calculate this for your data, you have got the distribution of the values for the assumed distribution. I have got 63.0875 for the average value, and with that the error is below 0.004 for each point.

Another way is to use the above relation and create a linear dependency

$$TTR^2\cdot N=-D(TTR,N)\cdot(2(TTR-1))$$

Now you can use various methods for linear interpolation and obtain $D(TTR,N)$. There are other methods but this should help.

You should set the goal and specify what you want to minimize and then calculate the constant based on that requirement.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .