import numpy as np

# Generate an array of 100 random numbers between 0 and 1
D = np.random.uniform(0, 1, 100)

# Generate an array of 100 random integers between 0 and 9
S = np.random.randint(0, 10, 100)

# Count the number of occurrences of each value in S
D_counts = np.bincount(S)

# Find the unique values in S and their corresponding indices
unique_vals, group_indices = np.unique(S, return_inverse=True)

# Sum the D values for each group of unique values in S
D_sums = np.add.reduceat(D, np.concatenate(([0], np.cumsum(D_counts[:-1]))))

# Calculate the mean of the D values for each group of unique values in S
D_means = D_sums / D_counts

# Print the mean of the D values for each group of unique values in S
print(D_means)