src/estimagic/optimization/trust_region_sampling.py
def _extend_upscaled_lhs_sample(empty_bins, n_points, n_designs, dtype=np.uint8):
    """Extend a sample to a full Latin hypercube sample (LHS).

    Args:
        empty_bins (np.ndarray): Dimensionality of the problem.
        n_points (int): Number of (total) sample points.
        n_designs (int): Number of different hypercubes to sample.
        dtype (np.uint8 or np.unt16): Data type of arrays. Default np.unint8.

    Returns:
        sample (np.ndarray): Latin Hypercube sample of shape (n_designs, n_samples,
            n_dim)

    """
    mask = empty_bins == -1
    n_new_points, n_dim = empty_bins.shape

    sample = np.empty((n_designs, n_dim, n_new_points), dtype=dtype)

    for j in range(n_dim):
        empty = empty_bins[:, j].copy()
        n_duplicates = mask[:, j].sum()
        empty[mask[:, j]] = np.random.choice(n_points, size=n_duplicates, replace=False)
        for k in range(n_designs):
            np.random.shuffle(empty)
            sample[k, j] = empty

    sample = sample.swapaxes(1, 2)
    return sample
Extend a sample to a full Latin hypercube sample (LHS).

    Args:
        empty_bins (np.ndarray): Dimensionality of the problem.
        n_points (int): Number of (total) sample points.
        n_designs (int): Number of different hypercubes to sample.
        dtype (np.uint8 or np.unt16): Data type of arrays. Default np.unint8.

    Returns:
        sample (np.ndarray): Latin Hypercube sample of shape (n_designs, n_samples,
            n_dim)

    
Extend a sample to a full Latin hypercube sample (LHS).
Extend a sample to a full Latin hypercube sample ( LHS ) .
def _extend_upscaled_lhs_sample(empty_bins, n_points, n_designs, dtype=np.uint8):
    mask = empty_bins == -1
    n_new_points, n_dim = empty_bins.shape
    sample = np.empty((n_designs, n_dim, n_new_points), dtype=dtype)
    for j in range(n_dim):
        empty = empty_bins[:, j].copy()
        n_duplicates = mask[:, j].sum()
        empty[mask[:, j]] = np.random.choice(n_points, size=n_duplicates, replace=False)
        for k in range(n_designs):
            np.random.shuffle(empty)
            sample[k, j] = empty
    sample = sample.swapaxes(1, 2)
    return sample
def _extend_upscaled_lhs_sample ( empty_bins , n_points , n_designs , dtype = np . uint8 ) : mask = empty_bins == - 1 n_new_points , n_dim = empty_bins . shape sample = np . empty ( ( n_designs , n_dim , n_new_points ) , dtype = dtype ) for j in range ( n_dim ) : empty = empty_bins [ : , j ] . copy ( ) n_duplicates = mask [ : , j ] . sum ( ) empty [ mask [ : , j ] ] = np . random . choice ( n_points , size = n_duplicates , replace = False ) for k in range ( n_designs ) : np . random . shuffle ( empty ) sample [ k , j ] = empty sample = sample . swapaxes ( 1 , 2 ) return sample
Extend a sample to a full Latin hypercube sample (LHS).
Extend a sample to a full Latin hypercube sample ( LHS ) .
"""Extend a sample to a full Latin hypercube sample (LHS).

    Args:
        empty_bins (np.ndarray): Dimensionality of the problem.
        n_points (int): Number of (total) sample points.
        n_designs (int): Number of different hypercubes to sample.
        dtype (np.uint8 or np.unt16): Data type of arrays. Default np.unint8.

    Returns:
        sample (np.ndarray): Latin Hypercube sample of shape (n_designs, n_samples,
            n_dim)

    """
sample (np.ndarray): Latin Hypercube sample of shape (n_designs, n_samples,
n_dim)
sample ( np . ndarray ) : Latin Hypercube sample of shape ( n_designs n_samples n_dim )
empty_bins
Dimensionality of the problem.
Dimensionality of the problem .
n_points
Number of (total) sample points.
Number of ( total ) sample points .
n_designs
Number of different hypercubes to sample.
Number of different hypercubes to sample .
dtype
Data type of arrays. Default np.unint8.
Data type of arrays . Default np . unint8 .