Ejemplo n.º 1
0
        model_partials = [partial1_exponential, partial2_exponential]
        model_pivotfunc = get_pivot_exponential

    elif functionType == 'Logarithmic':
        model_function = function_logarithmic
        model_partials = [partial1_logarithmic]
        model_pivotfunc = get_pivot_logarithmic

    else:
        #return
        print("hi")

    #Rejection tech determination:
    rejTechInt = int(rejType)

    r = rcr.RCR()

    rejTech = ''
    if symDist:
        if equalCont:
            r.setRejectionTech(rcr.SS_MEDIAN_DL)
            rejTech = 'ss_med_dl'
        elif oneSidedCont:
            r.setRejectionTech(rcr.LS_MODE_68)
            rejTech = 'ls_mode_68'
        elif inBetweenCont:
            r.setRejectionTech(rcr.LS_MODE_DL)
            rejTech = 'ls_mode_dl'
    else:
        r.setRejectionTech(rcr.ES_MODE_DL)
        rejTech = 'es_mode_dl'
Ejemplo n.º 2
0
ax.set_position([box.x0, box.y0, box.width * 0.65, box.height])
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

plt.show()

# get results pre-RCR
contaminated_mu = np.mean(data)
contaminated_sigma = np.std(data)
print(contaminated_mu, contaminated_sigma)

# perform RCR
import rcr

# initialize RCR with rejection technique:
# (chosen from shape of uncontaminated + contaminated distribution)
r = rcr.RCR(rcr.SS_MEDIAN_DL)
r.performBulkRejection(data)  # perform outlier rejection

# View results post-RCR
cleaned_mu = r.result.mu
cleaned_sigma = r.result.stDev
print(cleaned_mu, cleaned_sigma)

# plot rejections
cleaned_data = r.result.cleanY

flags = r.result.flags
# list of booleans corresponding to the original dataset,
# true if the corresponding datapoint is not an outlier.

cleaned_data_indices = r.result.indices
Ejemplo n.º 3
0
# for Travis
import rcr

data = [0, 0.1, -0.1, 0.2, -0.2, 1e50]

r = rcr.RCR(rcr.LS_MODE_68)
r.performBulkRejection(data)  # perform outlier rejection

# View results
rejected_data = r.result.rejectedY

assert len(rejected_data) >= 1

print(len(rejected_data))
Ejemplo n.º 4
0
    return x - rcr.FunctionalForm.pivot

def get_pivot(xdata, weights, f, params):
    sum = 0
    for x in xdata:
        sum += x
    return sum / len(xdata)

# if __name__ == "__main__":
y = [0.1, 0.2, 0, 0.3, -0.1, -0.2, -0.3, 11]
w = [0.5, 1.0, 1.2, 3.0, 1.0, 0.6, 0.2, 1.0, 0.1, 0.05]

y = np.array(y)
w = np.array(w)

rcr_obj = rcr.RCR(rcr.ES_MODE_DL)
rcr_obj.performBulkRejection(w, y)

print(rcr_obj.result.flags)


tolerance = 0.01
guess = [2.1, 0.9]
y = [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 20.0, 11.0]
x = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
w = [0.5, 1.0, 1.2, 3.0, 1.0, 0.6, 0.2, 1.0, 0.1, 2.0]
err_y = [0.1 for xx in x]

gaussianParams =    [[float('nan'), float('nan')], [1.0, 2.0] ]
boundedParams =     [[0.0, float('nan')], [float('nan'), float('nan')] ]
priors = rcr.Priors(rcr.MIXED_PRIORS, gaussianParams, boundedParams)
Ejemplo n.º 5
0
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.65, box.height])
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))

plt.show()

# initialize model and guess for model parameters

guess = [5, 1.5]

model = rcr.FunctionalForm(linear, xdata, ydata, [d_linear_1, d_linear_2],
                           guess)

# initialize and perform RCR

r = rcr.RCR(rcr.LS_MODE_68)  # setting up for RCR with this rejection technique

r.setParametricModel(model)  # tell RCR that we are model fitting

r.performBulkRejection(ydata)  # perform RCR

# view results
best_fit_parameters = model.result.parameters  # best fit parameters

rejected_data = r.result.rejectedY  # rejected and non-rejected data
nonrejected_data = r.result.cleanY
nonrejected_indices = r.result.indices

print(best_fit_parameters)

# plot results