How to use the probscale.algo._estimate_from_fit function in probscale

To help you get started, we’ve selected a few probscale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Geosyntec / wqio / wqio / theil.py View on Github external
def med_estimate(self):
        return _estimate_from_fit(
            self.influent_data,
            self.med_slope,
            self.intercept,
            xlog=self.log_infl,
            ylog=self.log_effl,
        )
github Geosyntec / wqio / wqio / features.py View on Github external
"medslope": theilstats[0],
                    "intercept": theilstats[1],
                    "loslope": theilstats[2],
                    "hislope": theilstats[3],
                    "is_inverted": inverted,
                }
            else:
                output = {
                    "medslope": 1 / theilstats[0],
                    "intercept": -1 * theilstats[1] / theilstats[0],
                    "loslope": 1 / theilstats[2],
                    "hislope": 1 / theilstats[3],
                    "is_inverted": inverted,
                }

            output["estimated_effluent"] = _estimate_from_fit(
                infl,
                output["medslope"],
                output["intercept"],
                xlog=log_infl,
                ylog=log_effl,
            )

            output["estimate_error"] = (
                self.paired_data.outflow.res.values - output["estimated_effluent"]
            )

        return output
github Geosyntec / wqio / wqio / utils / numutils.py View on Github external
if fitlogs in ["x", "both"]:
        x = numpy.log(x)

    if fitlogs in ["y", "both"]:
        y = numpy.log(y)

    x = sm.add_constant(x)

    # fix the y-intercept at 0 if requested
    # note that this is a nuance of the statsmodels package.
    # `x[:, 0] = 5` doesn't fix the intercept at 5, for instance.
    if through_origin:
        x[:, 0] = 0

    results = sm.OLS(y, x).fit()
    yhat = _estimate_from_fit(
        xhat,
        results.params[1],
        results.params[0],
        xlog=fitlogs in ["x", "both"],
        ylog=fitlogs in ["y", "both"],
    )

    if fitprobs in ["y", "both"]:
        yhat = 100.0 * dist.cdf(yhat)
    if fitprobs in ["x", "both"]:
        xhat = 100.0 * dist.cdf(xhat)

    return xhat, yhat, results
github Geosyntec / wqio / wqio / bootstrap.py View on Github external
y = numpy.log(y)

    # compute fit on original data
    main_params = fitfxn(x, y, **kwargs)

    # raw loop to estimate the bootstrapped fit parameters
    bs_params = numpy.array(
        [fitfxn(x[ii], y[ii], **kwargs) for ii in _make_boot_index(len(x), niter)]
    )

    # un-log, if necesssary
    if xlog:
        x = numpy.exp(x)

    # compute estimate from original data fit
    yhat = _estimate_from_fit(x, main_params[0], main_params[1], xlog=xlog, ylog=ylog)

    # full array of estimates
    bs_estimates = _estimate_from_fit(
        x[:, None], bs_params[:, 0], bs_params[:, 1], xlog=xlog, ylog=ylog
    )

    # both alpha alphas
    percentiles = 100 * numpy.array([alpha * 0.5, 1 - alpha * 0.5])

    # lower, upper bounds
    bounds = numpy.percentile(bs_estimates, percentiles, axis=1)

    return fitestimate(x, yhat, bounds[0], bounds[1], xlog, ylog)
github Geosyntec / wqio / wqio / bootstrap.py View on Github external
main_params = fitfxn(x, y, **kwargs)

    # raw loop to estimate the bootstrapped fit parameters
    bs_params = numpy.array(
        [fitfxn(x[ii], y[ii], **kwargs) for ii in _make_boot_index(len(x), niter)]
    )

    # un-log, if necesssary
    if xlog:
        x = numpy.exp(x)

    # compute estimate from original data fit
    yhat = _estimate_from_fit(x, main_params[0], main_params[1], xlog=xlog, ylog=ylog)

    # full array of estimates
    bs_estimates = _estimate_from_fit(
        x[:, None], bs_params[:, 0], bs_params[:, 1], xlog=xlog, ylog=ylog
    )

    # both alpha alphas
    percentiles = 100 * numpy.array([alpha * 0.5, 1 - alpha * 0.5])

    # lower, upper bounds
    bounds = numpy.percentile(bs_estimates, percentiles, axis=1)

    return fitestimate(x, yhat, bounds[0], bounds[1], xlog, ylog)