def CONDMAX(*arg): """ Conditional maximum function. Conputes a rv X, consisting of the maximum of performance if corresponding num is greater than 0 for each MC trial. Args: arg: Sympy parsed arguments, [n0, p0, n1, p1, ...] each n, p can be either a distribution or a scalar. Return: x: result distribution. """ ns = arg[::2] ps = arg[1::2] assert ns and ps and len(ns) == len(ps) if not __has_distribution(ns) and not __has_distribution(ps): candidate = [p for n, p in zip(ns, ps) if n > 0] return max(candidate) else: x = Distribution.GetDummy() mcpts = [None] * mcp.npts for i in range(mcp.npts): candidate = [ p._mcpts[i] if isinstance(p, UncertainFunction) else p for n, p in zip(ns, ps) if (n._mcpts[i] if isinstance(n, UncertainFunction) else n) > 0 ] mcpts[i] = max( candidate) if candidate else Distribution.NON_ZERO_FACTOR x._mcpts = np.asarray(mcpts) return x
def pollack_boxcox_uncertainty(d, perc): mean = get_pollack(d) std = mean * perc gt_perf = pollack_uncertainty(d, perc) if std: return Distribution.DistributionFromBoxCoxGaussian(mean, std, gt_perf._mcpts, lower=0) else: return gt_perf
def fabrication_boxcox_uncertainty(d, n): if n > 0: func = UncertaintyModel.fabrication() gt = func(d, n) tgt_mean = gt.mean tgt_std = gt.var ** .5 return Distribution.DistributionFromBoxCoxGaussian(tgt_mean, tgt_std, gt._mcpts, lower=0) else: return 0
def design_pollack_boxcox_uncertainty(d, p0, perc): mean = get_pollack(d) std = mean * perc gt_perf = design_pollack_uncertainty(d, p0, perc) if std: tgt_mean = gt_perf.mean tgt_std = gt_perf.var ** .5 return Distribution.DistributionFromBoxCoxGaussian(tgt_mean, tgt_std, gt_perf._mcpts, lower=0) else: return gt_perf
def design_pollack_gaussian_uncertainty(d, p0, perc, a=None, b=None): mean = get_pollack(d) std = perc * mean return Distribution.QGaussianDistribution(p0, mean, std, a, b)
def design_pollack_uncertainty(d, p0, perc): mean = get_pollack(d) std = perc * mean return Distribution.QLogNormalDistribution(p0, mean, std)
def pollack_uncertainty(d, perc): mean = get_pollack(d) std = perc * mean return Distribution.LogNormalDistribution(mean, std)
def higher_order_bernoulli(d, num, func): return Distribution.HigherOrderBernoulli(func(d), num)