def calc_errorcomponent(self, variance_norm, variance_halfnorm, 
                            vertex, size, seed):
        """
        The method returns the contribution of the error component in the 
        calculation of the predicted value for the different choices.
        
        Inputs:
        variance_norm - numeric value (variance of the normal portion of error)
        variance_halfnorm - numeric value (variance of the half normal portion of
                                        error)
        vertex - string (the vertext to predict -- start/end)
        size - numeric value (number of rows)

        """

        dist = RandomDistribution(seed=seed)
	err_halfnorm = dist.return_half_normal_variables(location=0, scale=variance_halfnorm**0.5, size=size)

	dist = RandomDistribution(seed=seed)
        err_norm = dist.return_normal_variables(location=0, scale=variance_norm**0.5, size=size)

        if vertex == 'start':
            return err_norm + err_halfnorm

        if vertex == 'end':
            return err_norm - err_halfnorm
    def calc_errorcomponent(self, variance_norm, variance_halfnorm, vertex,
                            size, seed):
        """
        The method returns the contribution of the error component in the
        calculation of the predicted value for the different choices.

        Inputs:
        variance_norm - numeric value (variance of the normal portion of error)
        variance_halfnorm - numeric value (variance of the half normal portion of
                                        error)
        vertex - string (the vertext to predict -- start/end)
        size - numeric value (number of rows)

        """

        dist = RandomDistribution(seed=seed)
        err_halfnorm = dist.return_half_normal_variables(
            location=0, scale=variance_halfnorm**0.5, size=size)

        dist = RandomDistribution(seed=seed)
        err_norm = dist.return_normal_variables(location=0,
                                                scale=variance_norm**0.5,
                                                size=size)

        if vertex == 'start':
            return err_norm + err_halfnorm

        if vertex == 'end':
            return err_norm - err_halfnorm
Exemplo n.º 3
0
    def calc_halfnormal_error(self, threshold, limit, seed, size):
	"""
	A draw from a half normal distribution with 3 s.d. = abs(threshold - limit)
	For smoothing about the boundaries

	"""

	dist = RandomDistribution(seed=seed)

	assu_scale = abs(threshold-limit)/3.0
	err_halfnorm = dist.return_half_normal_variables(location=0, scale=assu_scale, size=size)

	chkRowsMore = err_halfnorm > abs(threshold-limit)
	err_halfnorm[chkRowsMore] = abs(threshold-limit)
	
	return err_halfnorm