(params, bounds, dists)
return conv_params
Rescale samples in 0-to-1 range to other distributions

    Parameters
    ----------
    problem : dict
        problem definition including bounds
    params : numpy.ndarray
        numpy array of dimensions num_params-by-N,
        where N is the number of samples
    dists : list
        list of distributions, one for each parameter
            unif: uniform with lower and upper bounds
            triang: triangular with width (scale) and location of peak
                    location of peak is in percentage of width
                    lower bound assumed to be zero
            norm: normal distribution with mean and standard deviation
            truncnorm: truncated normal distribution with upper and lower
                    bounds, mean and standard deviation
            lognorm: lognormal with ln-space mean and standard deviation
Rescale samples in 0-to-1 range to other distributions
Rescale samples in 0 - to - 1 range to other distributions
def _nonuniform_scale_samples(params, bounds, dists):
    """Rescale samples in 0-to-1 range to other distributions

    Parameters
    ----------
    problem : dict
        problem definition including bounds
    params : numpy.ndarray
        numpy array of dimensions num_params-by-N,
        where N is the number of samples
    dists : list
        list of distributions, one for each parameter
            unif: uniform with lower and upper bounds
            triang: triangular with width (scale) and location of peak
                    location of peak is in percentage of width
                    lower bound assumed to be zero
            norm: normal distribution with mean and standard deviation
            truncnorm: truncated normal distribution with upper and lower
                    bounds, mean and standard deviation
            lognorm: lognormal with ln-space mean and standard deviation
    """
    b = np.array(bounds)

    # initializing matrix for converted values
    conv_params = np.empty_like(params)

    # loop over the parameters
    for i in range(conv_params.shape[1]):
        # setting first and second arguments for distributions
        b1 = b[i][0]
        b2 = b[i][1]

        if dists[i] == 'triang':
            # checking for correct parameters
            if b1 <= 0 or b2 <= 0 or b2 >= 1:
                raise ValueError("""Triangular distribution: Scale must be
                    greater than zero; peak on interval [0,1]""")
            else:
                conv_params[:, i] = sp.stats.triang.ppf(
                    params[:, i], c=b2, scale=b1, loc=0)

        elif dists[i] == 'unif':
            if b1 >= b2:
                raise ValueError("""Uniform distribution: lower bound
                    must be less than upper bound""")
            else:
                conv_params[:, i] = params[:, i] * (b2 - b1) + b1

        elif dists[i] == 'norm':
            if b2 <= 0:
                raise ValueError("""Normal distribution: stdev must be > 0""")
            else:
                conv_params[:, i] = sp.stats.norm.ppf(
                    params[:, i], loc=b1, scale=b2)

        # Truncated normal distribution
        # parameters are lower bound and upper bound, mean and stdev
        elif dists[i] == 'truncnorm':
            b3 = b[i][2]
            b4 = b[i][3]
            if b4 <= 0:
                raise ValueError(
                    """Truncated normal distribution: stdev must
                    be > 0"""
                )
            if b1 >= b2:
                raise ValueError(
                    """Truncated normal distribution: lower bound
                    must be less than upper bound"""
                )
            else:
                conv_params[:, i] = sp.stats.truncnorm.ppf(
                    params[:, i], (b1 - b3) / b4, (b2 - b3) / b4, loc=b3, scale=b4
                )

        # lognormal distribution (ln-space, not base-10)
        # paramters are ln-space mean and standard deviation
        elif dists[i] == 'lognorm':
            # checking for valid parameters
            if b2 <= 0:
                raise ValueError(
                    """Lognormal distribution: stdev must be > 0""")
            else:
                conv_params[:, i] = np.exp(
                    sp.stats.norm.ppf(params[:, i], loc=b1, scale=b2))

        else:
            valid_dists = ['unif', 'triang', 'norm', 'truncnorm', 'lognorm']
            raise ValueError('Distributions: choose one of %s' %
                             ", ".join(valid_dists))

    return conv_params
def _nonuniform_scale_samples ( params , bounds , dists ) : b = np . array ( bounds ) # initializing matrix for converted values conv_params = np . empty_like ( params ) # loop over the parameters for i in range ( conv_params . shape [ 1 ] ) : # setting first and second arguments for distributions b1 = b [ i ] [ 0 ] b2 = b [ i ] [ 1 ] if dists [ i ] == 'triang' : # checking for correct parameters if b1 <= 0 or b2 <= 0 or b2 >= 1 : raise ValueError ( """Triangular distribution: Scale must be
                    greater than zero; peak on interval [0,1]""" ) else : conv_params [ : , i ] = sp . stats . triang . ppf ( params [ : , i ] , c = b2 , scale = b1 , loc = 0 ) elif dists [ i ] == 'unif' : if b1 >= b2 : raise ValueError ( """Uniform distribution: lower bound
                    must be less than upper bound""" ) else : conv_params [ : , i ] = params [ : , i ] * ( b2 - b1 ) + b1 elif dists [ i ] == 'norm' : if b2 <= 0 : raise ValueError ( """Normal distribution: stdev must be > 0""" ) else : conv_params [ : , i ] = sp . stats . norm . ppf ( params [ : , i ] , loc = b1 , scale = b2 ) # Truncated normal distribution # parameters are lower bound and upper bound, mean and stdev elif dists [ i ] == 'truncnorm' : b3 = b [ i ] [ 2 ] b4 = b [ i ] [ 3 ] if b4 <= 0 : raise ValueError ( """Truncated normal distribution: stdev must
                    be > 0""" ) if b1 >= b2 : raise ValueError ( """Truncated normal distribution: lower bound
                    must be less than upper bound""" ) else : conv_params [ : , i ] = sp . stats . truncnorm . ppf ( params [ : , i ] , ( b1 - b3 ) / b4 , ( b2 - b3 ) / b4 , loc = b3 , scale = b4 ) # lognormal distribution (ln-space, not base-10) # paramters are ln-space mean and standard deviation elif dists [ i ] == 'lognorm' : # checking for valid parameters if b2 <= 0 : raise ValueError ( """Lognormal distribution: stdev must be > 0""" ) else : conv_params [ : , i ] = np . exp ( sp . stats . norm . ppf ( params [ : , i ] , loc = b1 , scale = b2 ) ) else : valid_dists = [ 'unif' , 'triang' , 'norm' , 'truncnorm' , 'lognorm' ] raise ValueError ( 'Distributions: choose one of %s' % ", " . join ( valid_dists ) ) return conv_params