Beispiel #1
0
def _check_bayesfit_batch_process(branch):
    # Generate dataset
    data_batch = np.array([[0.0010, 45.0000, 90.0000],
                           [0.0015, 50.0000, 90.0000],
                           [0.0020, 44.0000, 90.0000],
                           [0.0025, 44.0000, 90.0000],
                           [0.0030, 52.0000, 90.0000],
                           [0.0035, 53.0000, 90.0000],
                           [0.0040, 62.0000, 90.0000],
                           [0.0045, 64.0000, 90.0000],
                           [0.0050, 76.0000, 90.0000],
                           [0.0060, 79.0000, 90.0000],
                           [0.0070, 88.0000, 90.0000],
                           [0.0080, 90.0000, 90.0000],
                           [0.0100, 90.0000, 90.0000]])
    # Create batch data object
    data = dict()
    data['data01'] = data_batch
    data['data02'] = data_batch
    # Choose branch that defines sigmoid fit
    if branch == 0:
        param_free = [True, True, False, False]
    elif branch == 1:
        param_free = [True, True, True, False]
    elif branch == 2:
        param_free = [True, True, True, True]
    # Use BayesFit to fit function
    metrics, options = bf.fitmodel(data,
                                   batch=True,
                                   param_free=param_free,
                                   density=20)
    # Update success flag
    success = 1
    return success
Beispiel #2
0
def _check_bayesfit_psyfunctions(branch):
    # Generate dataset
    data = np.array([[0.0010, 45.0000, 90.0000], [0.0015, 50.0000, 90.0000],
                     [0.0020, 44.0000, 90.0000], [0.0025, 44.0000, 90.0000],
                     [0.0030, 52.0000, 90.0000], [0.0035, 53.0000, 90.0000],
                     [0.0040, 62.0000, 90.0000], [0.0045, 64.0000, 90.0000],
                     [0.0050, 76.0000, 90.0000], [0.0060, 79.0000, 90.0000],
                     [0.0070, 88.0000, 90.0000], [0.0080, 90.0000, 90.0000],
                     [0.0100, 90.0000, 90.0000]])
    # Choose branch that defines sigmoid fit
    if branch == 0:
        sigmoid_type = 'logistic'
    elif branch == 1:
        sigmoid_type = 'weibull'
    elif branch == 2:
        sigmoid_type = 'gumbel'
    elif branch == 3:
        sigmoid_type = 'quick'
    elif branch == 4:
        sigmoid_type = 'log-quick'
    elif branch == 5:
        sigmoid_type = 'hyperbolic'
    elif branch == 6:
        sigmoid_type = 'norm'
    # Use BayesFit to fit function
    metrics, options = bf.fitmodel(data,
                                   sigmoid_type=sigmoid_type,
                                   logspace=False)
    # Update success flag
    success = 1
    return success
Beispiel #3
0
def _check_plot_cdf():
    # Generate dataset
    x = [0.1, 0.21, 0.33, 0.44, 0.55, 0.66, 0.78, 0.9]
    y = [0.48, 0.47, 0.53, 0.55, 0.73, 0.83, 0.97, 0.96]
    N = [100, 100, 100, 100, 100, 100, 100, 100]
    data = np.array([x, y, N]).T
    # Use BayesFit to fit function
    trace, metrics, options = bf.fitmodel(data)
    # Generate cdf plot
    bf.plot_cdf(data, metrics, options)
    # Update success flag
    success = 1
    return success
Beispiel #4
0
def _check_geweke_plot():
    # Generate dataset
    x = [0.1, 0.21, 0.33, 0.44, 0.55, 0.66, 0.78, 0.9]
    y = [0.48, 0.47, 0.53, 0.55, 0.73, 0.83, 0.97, 0.96]
    N = [100, 100, 100, 100, 100, 100, 100, 100]
    data = np.array([x, y, N]).T
    # Use BayesFit to fit function
    trace, metrics, options = bf.fitmodel(data)
    # Generate geweke plot
    bf.geweke_plot(trace=trace['alpha'], intervals=10, length=300)
    # Update success flag
    success = 1
    return success
Beispiel #5
0
def _check_bayesfit_priors():
    # Generate dataset
    data = np.array([[0.0010, 45.0000, 90.0000], [0.0015, 50.0000, 90.0000],
                     [0.0020, 44.0000, 90.0000], [0.0025, 44.0000, 90.0000],
                     [0.0030, 52.0000, 90.0000], [0.0035, 53.0000, 90.0000],
                     [0.0040, 62.0000, 90.0000], [0.0045, 64.0000, 90.0000],
                     [0.0050, 76.0000, 90.0000], [0.0060, 79.0000, 90.0000],
                     [0.0070, 88.0000, 90.0000], [0.0080, 90.0000, 90.0000],
                     [0.0100, 90.0000, 90.0000]])
    priors = ['Norm(0.005,0.001)', 'Norm(3,0.75)', None, None]
    metrics, options = bf.fitmodel(data,
                                   priors=priors,
                                   sigmoid_type='weibull',
                                   logspace=False)
    # Update success flag
    success = 1
    return success
Beispiel #6
0
def _check_bayesfit_param_constraints(branch):
    # Generate dataset
    x = [0.1, 0.21, 0.33, 0.44, 0.55, 0.66, 0.78, 0.9]
    y = [0.48, 0.47, 0.53, 0.55, 0.73, 0.83, 0.97, 0.96]
    N = [100, 100, 100, 100, 100, 100, 100, 100]
    data = np.array([x, y, N]).T
    # Choose branch that defines sigmoid fit
    if branch == 0:
        param_constraints = [True, True, False, False]
    elif branch == 1:
        param_constraints = [True, True, True, False]
    elif branch == 2:
        param_constraints = [True, True, True, True]
    # Use BayesFit to fit function
    trace, metrics, options = bf.fitmodel(data,
                                          param_constraints=param_constraints)
    # Update success flag
    success = 1
    return success
Beispiel #7
0
def _check_plot_marginals():    
    # Generate dataset 
    data = np.array([[0.0010,   45.0000,   90.0000],
                     [0.0015,   50.0000,   90.0000],
                     [0.0020,   44.0000,   90.0000],
                     [0.0025,   44.0000,   90.0000],
                     [0.0030,   52.0000,   90.0000],
                     [0.0035,   53.0000,   90.0000],
                     [0.0040,   62.0000,   90.0000],
                     [0.0045,   64.0000,   90.0000],
                     [0.0050,   76.0000,   90.0000],
                     [0.0060,   79.0000,   90.0000],
                     [0.0070,   88.0000,   90.0000],
                     [0.0080,   90.0000,   90.0000],
                     [0.0100,   90.0000,   90.0000]]);
    # Use BayesFit to fit function
    metrics, options = bf.fitmodel(data, sigmoid_type = 'norm')
    # Generate geweke plot
    bf.plot_marginals(metrics)
    # Update success flag
    success = 1
    return success 
Beispiel #8
0
def _check_bayesfit_psyfunctions(branch):
    # Generate dataset
    x = [0.1, 0.21, 0.33, 0.44, 0.55, 0.66, 0.78, 0.9]
    y = [0.48, 0.47, 0.53, 0.55, 0.73, 0.83, 0.97, 0.96]
    N = [100, 100, 100, 100, 100, 100, 100, 100]
    data = np.array([x, y, N]).T
    # Choose branch that defines sigmoid fit
    if branch == 0:
        sigmoid_type = 'logistic'
    elif branch == 1:
        sigmoid_type = 'weibull'
    elif branch == 2:
        sigmoid_type = 'gumbel'
    elif branch == 3:
        sigmoid_type = 'quick'
    elif branch == 4:
        sigmoid_type = 'log-quick'
    elif branch == 5:
        sigmoid_type = 'hyperbolic'
    # Use BayesFit to fit function
    trace, metrics, options = bf.fitmodel(data, sigmoid_type=sigmoid_type)
    # Update success flag
    success = 1
    return success
Beispiel #9
0
import numpy as np
import bayesfit as bf

#################################################################
#  GENERATE DATAFRAME OF RESPONSES USING MOCS / MLE
#################################################################
data = np.array([[0.0010, 45.0000, 90.0000], [0.0015, 50.0000, 90.0000],
                 [0.0020, 44.0000, 90.0000], [0.0025, 44.0000, 90.0000],
                 [0.0030, 52.0000, 90.0000], [0.0035, 53.0000, 90.0000],
                 [0.0040, 62.0000, 90.0000], [0.0045, 64.0000, 90.0000],
                 [0.0050, 76.0000, 90.0000], [0.0060, 79.0000, 90.0000],
                 [0.0070, 88.0000, 90.0000], [0.0080, 90.0000, 90.0000],
                 [0.0100, 90.0000, 90.0000]])

metrics, options = bf.fitmodel(data, sigmoid_type='logistic')

#################################################################
#  GENERATE DATAFRAME OF RESPONSES USING STAIRCASE / MLE
#################################################################
data_stairs = np.array([[0.0010, 3.0000, 7.0000], [0.0015, 11.0000, 20.0000],
                        [0.0020, 17.0000, 35.0000], [0.0025, 7.0000, 15.0000],
                        [0.0030, 26.0000, 45.0000], [0.0035, 45.0000, 78.0000],
                        [0.0040, 55.0000, 80.0000], [0.0045, 64.0000, 90.0000],
                        [0.0050, 75.0000, 89.0000], [0.0060, 44.0000, 51.0000],
                        [0.0070, 19.0000, 20.0000], [0.0080, 7.0000, 7.0000],
                        [0.0100, 2.0000, 2.0000]])

metrics, options = bf.fitmodel(data_stairs, sigmoid_type='norm')

#################################################################