Fitting hyperbolic functions ($\tanh$) on data.

Suppose i have some data dependant on 2 variables n and T. If i plot this data choosing n= 5 and letting T vary from 1 to 100 i get the following curve: Where the blue curve is my real data and the yellow curve is the function $FIT(n,T) = \tanh(\frac{T^{-2} n}{\log(4)})$. Is there a way to move my tangent line in the interval $1,10$ with some continuous deformation such that my function $FIT(n,T)$ fits the data? Furthermore does anyone have suggestions of other functions that may fit. The green line added is the function $G(5,T) = \frac{T^{-2}*5}{\log(4)}$ For the interested: The function i try to fit is of the form: $$F(\beta,n) = 1 - \sum_{k=0}^{n} {n \choose k} \left(\frac{e^{\beta}}{e^{\beta} + e^{-\beta}}\right)^{k}\left(\frac{e^{-\beta}}{e^{\beta} + e^{-\beta}}\right)^{n-k} \log_{2}(1+\left(e^{2\beta}\right)^{n-2k})$$ Where $\beta = \frac{1}{T}$. Note tat the above plots are on logarithmic scale, the usual plots look different. For example if n = 100: You can clearly see its convergence to some powerlaw function which is the green line: Here is also the slope of the loglogplot that we see of the function F(n,T): • Can you please double check the expression you post for $F$ is the right one? I tried to plot it and got something very different. Thanks – caverac Jun 5 '18 at 13:09
• the logarithm is the second logarithm so Log_{2}, This is what i filled in mathematica: q[a_, B_] := E^(aB)/(E^(aB) + E^(-a*B)) F[n_, B_] = 1 - Sum[Binomial[n, k]*q[1, B]^k (1 - q[1, B])^(n - k) Log[2, 1 + E^(2 B (n - 2 k))], {k, 0, n}] – Kees Til Jun 5 '18 at 13:56
• Note that i got a logarithmic scale as well, i will add the normal scaled functions right now – Kees Til Jun 5 '18 at 13:58
• The fact that is base-2 logarithm actually makes a difference, maybe you should add that to the post $\color{red}{\log_2}(\cdots)$ – caverac Jun 5 '18 at 14:05

You know a couple of things

• At low $T$ the function behaves as a constant $F \sim 1$

• At a given temperature $T \sim T_0$ the function changes behavior

• For $T \gg T_0$ the function decays nearly as $F \sim T^{-2}$

A trial function that follows this constraints is

$$F(T) = \frac{F_0}{[1 + (T/T_0)^\gamma]^{2/\gamma}}$$

These are some results for $n = 5$

\begin{eqnarray} F_0 &=& 1.00628391 \\ T_0 &=&1.74144763 \\ \gamma &=& 3.2810511 \end{eqnarray}

which results in • I do understand that for low T you function F(T) goes to F_0, and i see that the term in the denominator converges to $T^{-2}$ for big $T$. However is there an ideal way to choose $\gamma$, $F_0$ and $T_0$? I see you have specific floats so i just assumed you used some optimiatization algorithm? – Kees Til Jun 5 '18 at 17:14
• @KeesTil yes, I just fitted my model to your function and found these values – caverac Jun 5 '18 at 17:19
• Nice, however this will probably not work if we try to fit in the $n$ dimension as well. I see that $F(T,n) \sim n$ for big $n$, so maybe adding up that information i can try finding a 2-dimensional fit. – Kees Til Jun 5 '18 at 17:31
• @KeesTil Effectively all parameters depend on $n$: $f_0 = f_0(n)$, $\gamma = \gamma(n)$ and $T_0 = T_0(n)$ – caverac Jun 5 '18 at 17:40