W1-Programming Assingment - Probability Distributions

Hello good afternoon, I am getting this error in Section 2.1: Generating the Dataset:


ValueError Traceback (most recent call last)
Cell In[37], line 35
31 return df
34 # Generate data for each breed
—> 35 df_0 = generate_data_for_breed(breed=0, features=FEATURES, n_samples=1200, params=breed_params)
36 df_1 = generate_data_for_breed(breed=1, features=FEATURES, n_samples=1350, params=breed_params)
37 df_2 = generate_data_for_breed(breed=2, features=FEATURES, n_samples=900, params=breed_params)

Cell In[37], line 27, in generate_data_for_breed(breed, features, n_samples, params)
24 df[feature] = binomial_generator(params[breed][feature].n, params[breed][feature].p, n_samples)
26 case “ear_head_ratio”:
—> 27 df[feature] = uniform_generator(params[breed][feature].a, params[breed][feature].b, n_samples)
29 df[“breed”] = breed
31 return df

Cell In[2], line 17, in uniform_generator(a, b, num_samples)
14 np.random.seed(42)
16 ### START CODE HERE ###
—> 17 array = np.random.default_rng().uniform(low=a, high=b, size=num_samples)
19 ### END CODE HERE ###
21 return array

File _generator.pyx:949, in numpy.random._generator.Generator.uniform()

File _common.pyx:616, in numpy.random._common.cont()

File _common.pyx:422, in numpy.random._common.check_constraint()

ValueError: high - low < 0

Hi @Carlos_Merino, it looks like there is an issue in your generator functions. Can you send me your notebook via DM so I can take a look at your implementation?

Hi @Carlos_Merino, the issue is in the uniform_generator function, notice how the output of this cell does not match the expected output. You don’t need the default_rng() you defined in there. If you take it away, the rest of the code works normally.

thank you now it works fine

1 Like

@Carlos_Merino, could you edit the post where you shared your notebook and delete your notebook so the answers are not leaked? In the future please share your notebook via a private message :slight_smile:

how do you private message?

You click on an user’s name and it should prompt you the option to message that user