# C3\_W1\_Assignment\_Gaussian\_generator\_wrong\_graph

**URL:** <https://community.deeplearning.ai/t/c3-w1-assignment-gaussian-generator-wrong-graph/506964>\
**Category:** Probability & Statistics for Machine Learning &...\
**Tags:** week-module-1\
**Created:** [November 29, 2023, 7:25pm UTC](https://community.deeplearning.ai/t/c3-w1-assignment-gaussian-generator-wrong-graph/506964 "2023-11-29T19:25:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Winn](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sean\_Winn](https://community.deeplearning.ai/u/Sean_Winn)\
**Post date:** [November 29, 2023, 7:25pm UTC](https://community.deeplearning.ai/t/c3-w1-assignment-gaussian-generator-wrong-graph/506964/1 "2023-11-29T19:25:51Z")

</div>

Hello, when I generate my graph for the guassian generator, my output looks incorrect. Any help with what I am doing wrong?

 ![image](https://global.discourse-cdn.com/dlai/original/3X/0/9/09c860dfd1fae66ffaf8b0699e3416dea72e041b.png)

---

<div class="post-metadata">

**Author:** ![Sean\_Winn](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sean\_Winn](https://community.deeplearning.ai/u/Sean_Winn)\
**Post date:** [November 30, 2023, 1:13pm UTC](https://community.deeplearning.ai/t/c3-w1-assignment-gaussian-generator-wrong-graph/506964/2 "2023-11-30T13:13:52Z")

</div>

any help would be appreciated?

---

<div class="post-metadata">

**Author:** ![Muhammad\_Adan](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@Muhammad\_Adan](https://community.deeplearning.ai/u/Muhammad_Adan)\
**Post date:** [January 7, 2024, 3:09pm UTC](https://community.deeplearning.ai/t/c3-w1-assignment-gaussian-generator-wrong-graph/506964/4 "2024-01-07T15:09:54Z")

</div>

use this  
def binomial\_generator(n, p, num\_samples):  
“”"  
Generates an array of binomially distributed random numbers.

```
Args:
    n (int): The number of trials in the binomial distribution.
    p (float): The probability of success in each trial.
    num_samples (int): The number of samples to generate.

Returns:
    array: An array of binomially distributed random numbers.
"""
### START CODE HERE ###

# Generate an array with num_samples elements that distribute uniformally between 0 and 1
u = np.random.uniform(0, 1, num_samples)

# Use the uniform-distributed sample to generate binomial-distributed data
# Hint: You need to sample from the inverse of the CDF of the distribution you are generating
array = inverse_cdf_binomial(u, n, p)
### END CODE HERE ###
return array

```
