Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which beta is being calculated by get_optimal_temperature on tools.py? #8

Open
edsf70 opened this issue Dec 17, 2018 · 5 comments
Open

Comments

@edsf70
Copy link

edsf70 commented Dec 17, 2018

On tools.py which beta is calculated by get_optimal_temperature? Global or local beta? Would you please be so kind providing functions to calculate both? Thank you very much indeed!

@cdebacco
Copy link
Owner

This is the beta maximizing the conditional loglikelihood, i.e. the global one. It uses a root-finding method (brentq), to solve eq S39 of the paper (in the Supplementary Material).
I will upload in the next few days a similar equivalent to calculate the local one, i.e. an implementation for eq. S36.

I will also upload an alternative method: instead of solving via root-finding method, one can use scipy.optimize.fmin_l_bfgs_b() to make python search for the optimal parameter value in order to maximize a function. This method allows to define custom cost functions, scipy.optimize does the rest.

@cdebacco
Copy link
Owner

cdebacco commented Dec 18, 2018 via email

@edsf70
Copy link
Author

edsf70 commented Dec 20, 2018

This is the beta maximizing the conditional loglikelihood, i.e. the global one. It uses a root-finding method (brentq), to solve eq S39 of the paper (in the Supplementary Material). I will upload in the next few days a similar equivalent to calculate the local one, i.e. an implementation for eq. S36. I will also upload an alternative method: instead of solving via root-finding method, one can use scipy.optimize.fmin_l_bfgs_b() to make python search for the optimal parameter value in order to maximize a function. This method allows to define custom cost functions, scipy.optimize does the rest. Il giorno lun 17 dic 2018 alle ore 13:04 edsf70 notifications@github.com ha scritto:

On tools.py which beta is calculated by get_optimal_temperature? Global or local beta? Would you please be so kind providing functions to calculate both? Thank you very much indeed! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#8>, or mute the thread https://github.com/notifications/unsubscribe-auth/ARSx93_I3sx9u52wwdXd33Ad3o_DHy7gks5u54hagaJpZM4ZWOOf .

That would be great!!! Thank you very much indeed!!

@edsf70
Copy link
Author

edsf70 commented Jul 15, 2019

Would you please be so kind telling me if there is already an implementation for eq. S36 (local Beta)?

@nicholasdomene
Copy link

nicholasdomene commented Nov 24, 2021

@edsf70 I've implemented it based on the eqs39 implementation and it turned out like this:

def eqs36(beta, s, A):
    N = A.shape[0]
    x = 0
    for i in range(N):
        for j in range(N):
            if A[i, j] == 0:
                continue
            else:
                pij =  1 / (1 + np.exp(-2 * beta * (s[i] - s[j])))
                signed = np.sign(A[i, j] - (A[i, j] + A[j, i])*pij)
                x += signed * ((A[i, j] - A[j, i])*(s[i] - s[j])) / ( np.cosh(2*beta*(s[i] - s[j])) + 1)
    return x

Only thing is that it is not nopython=True as eqs39, but it didn't seem an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants