Rewriting functions from r to python
Question:
I have function written in R.
V <- function(c, E, HS, EC_50) E + (1 - E) / (1 + exp(HS * (c - EC_50))
I would like to get the same function in Python but I don’t know how. I haven’t used Python very much before. Therefore, I am asking for forum help.
Answers:
I think this is what you are looking for:
import numpy as np
def v(c, E, HS, EC_50):
return E + (1 - E) / (1 + np.exp(HS * (c - EC_50)))
You can use lambda
expression
import numpy as np
v = lambda c, E, HS, EC_50: E + (1 - E) / (1 + np.exp(HS * (c - EC_50)))
I have function written in R.
V <- function(c, E, HS, EC_50) E + (1 - E) / (1 + exp(HS * (c - EC_50))
I would like to get the same function in Python but I don’t know how. I haven’t used Python very much before. Therefore, I am asking for forum help.
I think this is what you are looking for:
import numpy as np
def v(c, E, HS, EC_50):
return E + (1 - E) / (1 + np.exp(HS * (c - EC_50)))
You can use lambda
expression
import numpy as np
v = lambda c, E, HS, EC_50: E + (1 - E) / (1 + np.exp(HS * (c - EC_50)))