eccpy/tools.py
def hill_eq(hill_constants, x):
    """ Four parameter sigmoidal Hill equation.

    y = upper + (lower-upper)/(1+(x/EC50)**-hillslope)

    Parameters
    ----------
    hill_constants : tuple
        Tuple of the four parameters : upper, lower, EC50 and hillslope
    x : float
        x-value for use in the equation

    Constants
    ---------
    upper : float
        Renamed from "bottom" in some sources.
        Will approach the minimum response (perhaps zero) in the dose-response S-curve.
        Will approach the maximum response in an inverse LD50 curve.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
    lower : float
        Renamed from "top" in some sources.
        Will approach the maximum response in the dose-response S-curve.
        Will approach zero in an inverse LD50 curve.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
    EC50 : float
        Does not always accurately reflect the EC50 from the data.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
        Is not currently used as the calculated EC50 value.
    hillslope : float
        A high hillslope generally indicates a steep curve, an accurate EC50 calculation, and a strong sigmoidal shape.
        Note that the hillslope can be strongly negative.
        Hillslope values approaching zero (e.g. -1 > hill_slope > +1) generally indicate an exponential, rather than
        a sigmoidal curve. For this reason, hillslope is currently used as a parameter to judge whether the curve is
        sigmoidal, using the parameters chosen in the settings_excel_file and implemented in the "judge_fit" program.

    Notes
    -----
    The hill equation is used for the EC50 calculation, but there are several variants of the formula.

    Dose-Response Equations
    variant 1: http://www.graphpad.com/guides/prism/6/curve-fitting/index.htm?reg_classic_dr_variable.htm
    variant 2: http://en.wikipedia.org/wiki/EC50
    variant 3: http://pydoc.net/Python/cgptoolbox/0.1.2/cgp.sigmoidmodels.doseresponse/

    Sigmoid equations:
    variant 4: y = c * 1.0 / (1.0 + ((k/x)**g))
    variant 5: y = c / (1 + np.exp(-k*(x-x0))) + y0
        (http://stackoverflow.com/questions/7588371/scipy-leastsq-goodness-of-fit-estimator)

    This equation uses variant 2. See Wikipedia for a more detailed explanation.

    In theory, any formula that accurately fits a sigmoidal curve is appropriate for the purpose. The Hill equation
    is preferred, because under some circumstances the EC50 value is one of the fitted parameters in the hill_constants
    tuple. However this value is extremely unreliable, and regularly gives EC50 values that are out of the range of the
    datapoints. A more accurate EC50 calculation is achieved through root finding using the brent equation.

    """
    upper, lower, EC50, hillslope = hill_constants
    y = upper + (lower-upper)/(1+(x/EC50)**-hillslope)
    return y
 Four parameter sigmoidal Hill equation.

    y = upper + (lower-upper)/(1+(x/EC50)**-hillslope)

    Parameters
    ----------
    hill_constants : tuple
        Tuple of the four parameters : upper, lower, EC50 and hillslope
    x : float
        x-value for use in the equation

    Constants
    ---------
    upper : float
        Renamed from "bottom" in some sources.
        Will approach the minimum response (perhaps zero) in the dose-response S-curve.
        Will approach the maximum response in an inverse LD50 curve.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
    lower : float
        Renamed from "top" in some sources.
        Will approach the maximum response in the dose-response S-curve.
        Will approach zero in an inverse LD50 curve.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
    EC50 : float
        Does not always accurately reflect the EC50 from the data.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
        Is not currently used as the calculated EC50 value.
    hillslope : float
        A high hillslope generally indicates a steep curve, an accurate EC50 calculation, and a strong sigmoidal shape.
        Note that the hillslope can be strongly negative.
        Hillslope values approaching zero (e.g. -1 > hill_slope > +1) generally indicate an exponential, rather than
        a sigmoidal curve. For this reason, hillslope is currently used as a parameter to judge whether the curve is
        sigmoidal, using the parameters chosen in the settings_excel_file and implemented in the "judge_fit" program.

    Notes
    -----
    The hill equation is used for the EC50 calculation, but there are several variants of the formula.

    Dose-Response Equations
    variant 1: http://www.graphpad.com/guides/prism/6/curve-fitting/index.htm?reg_classic_dr_variable.htm
    variant 2: http://en.wikipedia.org/wiki/EC50
    variant 3: http://pydoc.net/Python/cgptoolbox/0.1.2/cgp.sigmoidmodels.doseresponse/

    Sigmoid equations:
    variant 4: y = c * 1.0 / (1.0 + ((k/x)**g))
    variant 5: y = c / (1 + np.exp(-k*(x-x0))) + y0
        (http://stackoverflow.com/questions/7588371/scipy-leastsq-goodness-of-fit-estimator)

    This equation uses variant 2. See Wikipedia for a more detailed explanation.

    In theory, any formula that accurately fits a sigmoidal curve is appropriate for the purpose. The Hill equation
    is preferred, because under some circumstances the EC50 value is one of the fitted parameters in the hill_constants
    tuple. However this value is extremely unreliable, and regularly gives EC50 values that are out of the range of the
    datapoints. A more accurate EC50 calculation is achieved through root finding using the brent equation.

    
Four parameter sigmoidal Hill equation.

Parameters

hill_constants : tuple
Tuple of the four parameters : upper, lower, EC50 and hillslope
x : float
x-value for use in the equation

Constants

upper : float
Renamed from "bottom" in some sources.
Will approach the minimum response (perhaps zero) in the dose-response S-curve.
Will approach the maximum response in an inverse LD50 curve.
Is not currently used as a parameter to judge whether curve is sigmoidal.
lower : float
Renamed from "top" in some sources.
Will approach the maximum response in the dose-response S-curve.
Will approach zero in an inverse LD50 curve.
Is not currently used as a parameter to judge whether curve is sigmoidal.
EC50 : float
Does not always accurately reflect the EC50 from the data.
Is not currently used as a parameter to judge whether curve is sigmoidal.
Is not currently used as the calculated EC50 value.
hillslope : float
A high hillslope generally indicates a steep curve, an accurate EC50 calculation, and a strong sigmoidal shape.
Note that the hillslope can be strongly negative.
Hillslope values approaching zero  generally indicate an exponential, rather than
a sigmoidal curve. For this reason, hillslope is currently used as a parameter to judge whether the curve is
sigmoidal, using the parameters chosen in the settings_excel_file and implemented in the "judge_fit" program.

Notes

The hill equation is used for the EC50 calculation, but there are several variants of the formula.



Sigmoid equations:
variant 4: y = c * 1.0 / (1.0 + ((k/x)**g))
variant 5: y = c / (1 + np.exp(-k*(x-x0))) + y0

This equation uses variant 2. See Wikipedia for a more detailed explanation.

In theory, any formula that accurately fits a sigmoidal curve is appropriate for the purpose. The Hill equation
is preferred, because under some circumstances the EC50 value is one of the fitted parameters in the hill_constants
tuple. However this value is extremely unreliable, and regularly gives EC50 values that are out of the range of the
datapoints. A more accurate EC50 calculation is achieved through root finding using the brent equation.
Four parameter sigmoidal Hill equation . Parameters hill_constants : tuple Tuple of the four parameters : upper lower EC50 and hillslope x : float x - value for use in the equation Constants upper : float Renamed from " bottom " in some sources . Will approach the minimum response ( perhaps zero ) in the dose - response S - curve . Will approach the maximum response in an inverse LD50 curve . Is not currently used as a parameter to judge whether curve is sigmoidal . lower : float Renamed from " top " in some sources . Will approach the maximum response in the dose - response S - curve . Will approach zero in an inverse LD50 curve . Is not currently used as a parameter to judge whether curve is sigmoidal . EC50 : float Does not always accurately reflect the EC50 from the data . Is not currently used as a parameter to judge whether curve is sigmoidal . Is not currently used as the calculated EC50 value . hillslope : float A high hillslope generally indicates a steep curve an accurate EC50 calculation and a strong sigmoidal shape . Note that the hillslope can be strongly negative . Hillslope values approaching zero generally indicate an exponential rather than a sigmoidal curve . For this reason hillslope is currently used as a parameter to judge whether the curve is sigmoidal using the parameters chosen in the settings_excel_file and implemented in the " judge_fit " program . Notes The hill equation is used for the EC50 calculation but there are several variants of the formula . Sigmoid equations : variant 4 : y = c * 1 . 0 / ( 1 . 0 + (( k / x ) ** g )) variant 5 : y = c / ( 1 + np . exp ( - k * ( x - x0 ))) + y0 This equation uses variant 2 . See Wikipedia for a more detailed explanation . In theory any formula that accurately fits a sigmoidal curve is appropriate for the purpose . The Hill equation is preferred because under some circumstances the EC50 value is one of the fitted parameters in the hill_constants tuple . However this value is extremely unreliable and regularly gives EC50 values that are out of the range of the datapoints . A more accurate EC50 calculation is achieved through root finding using the brent equation .
def hill_eq(hill_constants, x):
    upper, lower, EC50, hillslope = hill_constants
    y = upper + (lower-upper)/(1+(x/EC50)**-hillslope)
    return y
def hill_eq ( hill_constants , x ) : upper , lower , EC50 , hillslope = hill_constants y = upper + ( lower - upper ) / ( 1 + ( x / EC50 ) ** - hillslope ) return y
Four parameter sigmoidal Hill equation.
Four parameter sigmoidal Hill equation .
""" Four parameter sigmoidal Hill equation.

    y = upper + (lower-upper)/(1+(x/EC50)**-hillslope)

    Parameters
    ----------
    hill_constants : tuple
        Tuple of the four parameters : upper, lower, EC50 and hillslope
    x : float
        x-value for use in the equation

    Constants
    ---------
    upper : float
        Renamed from "bottom" in some sources.
        Will approach the minimum response (perhaps zero) in the dose-response S-curve.
        Will approach the maximum response in an inverse LD50 curve.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
    lower : float
        Renamed from "top" in some sources.
        Will approach the maximum response in the dose-response S-curve.
        Will approach zero in an inverse LD50 curve.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
    EC50 : float
        Does not always accurately reflect the EC50 from the data.
        Is not currently used as a parameter to judge whether curve is sigmoidal.
        Is not currently used as the calculated EC50 value.
    hillslope : float
        A high hillslope generally indicates a steep curve, an accurate EC50 calculation, and a strong sigmoidal shape.
        Note that the hillslope can be strongly negative.
        Hillslope values approaching zero (e.g. -1 > hill_slope > +1) generally indicate an exponential, rather than
        a sigmoidal curve. For this reason, hillslope is currently used as a parameter to judge whether the curve is
        sigmoidal, using the parameters chosen in the settings_excel_file and implemented in the "judge_fit" program.

    Notes
    -----
    The hill equation is used for the EC50 calculation, but there are several variants of the formula.

    Dose-Response Equations
    variant 1: http://www.graphpad.com/guides/prism/6/curve-fitting/index.htm?reg_classic_dr_variable.htm
    variant 2: http://en.wikipedia.org/wiki/EC50
    variant 3: http://pydoc.net/Python/cgptoolbox/0.1.2/cgp.sigmoidmodels.doseresponse/

    Sigmoid equations:
    variant 4: y = c * 1.0 / (1.0 + ((k/x)**g))
    variant 5: y = c / (1 + np.exp(-k*(x-x0))) + y0
        (http://stackoverflow.com/questions/7588371/scipy-leastsq-goodness-of-fit-estimator)

    This equation uses variant 2. See Wikipedia for a more detailed explanation.

    In theory, any formula that accurately fits a sigmoidal curve is appropriate for the purpose. The Hill equation
    is preferred, because under some circumstances the EC50 value is one of the fitted parameters in the hill_constants
    tuple. However this value is extremely unreliable, and regularly gives EC50 values that are out of the range of the
    datapoints. A more accurate EC50 calculation is achieved through root finding using the brent equation.

    """
hill_constants
x