import numpy as np from scipy.stats import qmc # 1. Define the number of new samples you want to generate num_samples = 26 # 2. Define the parameter space [min, max] for each variable # [Large Diameter D, Small Diameter d, Fillet Radius r] param_bounds = [ [14.0, 16.0], # Range for D [5.0, 7.5], # Range for d [1.0, 3.5] # Range for r ] # 3. Create the Latin Hypercube Sampler # The sampler generates points in a normalized space (between 0 and 1) # We use a seed for reproducibility, so you always get the same "random" set sampler = qmc.LatinHypercube(d=len(param_bounds), seed=42) unit_hypercube_samples = sampler.random(n=num_samples) # 4. Scale the normalized samples to your actual parameter ranges scaled_samples = qmc.scale(unit_hypercube_samples, [b[0] for b in param_bounds], [b[1] for b in param_bounds]) # 5. Print the results in your desired format print("--- Generated 26 New Shaft Combinations using LHS ---") for i, sample in enumerate(scaled_samples): # Ensure that d is always less than D # If by chance LHS generates d > D, we can swap them or adjust. # A simple approach is to ensure d is at least a certain amount smaller than D. D_val = sample[0] d_val = sample[1] # Simple constraint: ensure d is at most 95% of D if d_val >= D_val: d_val = D_val * 0.95 r_val = sample[2] # Format the output to one decimal place for clarity print(f"{i+1:2d}: life_D{D_val:.1f}_d{d_val:.1f}_r{r_val:.1f}")