Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Quality Control Sampling | Probability & Statistics
Mathematics for Data Science

bookChallenge: Quality Control Sampling

You are the quality control manager at a rod manufacturing factory. You need to simulate measurements and defect counts using three different probability distributions to model your production process:

  • Normal distribution for rod weights (continuous);
  • Binomial distribution for the number of defective rods in batches (discrete);
  • Uniform distribution for rod length tolerances (continuous).
Note
Note

Your task is to translate the formulas and concepts from your lecture into Python code. You must NOT use built-in numpy random sampling functions (e.g., np.random.normal) or any other library's direct sampling methods for the distributions. Instead, implement sample generation manually using the underlying principles and basic Python (e.g., random.random(), random.gauss()).

Formulas to Use

Normal distribution PDF:

f(x)=1σ2πe(xμ)22σ2f(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x - \mu)^2}{2\sigma^2}}

Standard deviation from variance:

σ=variance\sigma = \sqrt{\text{variance}}

Binomial distribution PMF:

P(X=k)=(nk)nk(1n)nk,where(nk)=n!k!(nk)!P(X = k) = \begin{pmatrix}n\\k\end{pmatrix}n^k(1-n)^{n-k},\quad \text{where}\begin{pmatrix}n\\k\end{pmatrix} = \frac{n!}{k!(n-k)!}

Uniform distribution PDF:

f(x)=1baforaxbf(x) = \frac{1}{b-a}\quad \text{for}\quad a \le x \le b
Завдання

Swipe to start coding

  1. Complete the starter code below by filling in the blanks (____) using the concepts/formulas above.
  2. Use only random and math modules.
  3. Implement three functions to generate 1000 samples from each distribution (Normal: using random.gauss(); Binomial: simulating n Bernoulli trials; Uniform: scaling random.random()).
  4. Plot histograms for each distribution (plotting code given, just complete the sampling functions and parameters).
  5. Retain all comments exactly as shown, they explain each step.
  6. No use of numpy random functions or external sampling libraries.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 5. Розділ 12
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain how to use these distributions for simulating the production process?

What are typical parameter values for each distribution in this context?

Can you provide an example of how to calculate probabilities using these formulas?

close

Awesome!

Completion rate improved to 1.89

bookChallenge: Quality Control Sampling

Свайпніть щоб показати меню

You are the quality control manager at a rod manufacturing factory. You need to simulate measurements and defect counts using three different probability distributions to model your production process:

  • Normal distribution for rod weights (continuous);
  • Binomial distribution for the number of defective rods in batches (discrete);
  • Uniform distribution for rod length tolerances (continuous).
Note
Note

Your task is to translate the formulas and concepts from your lecture into Python code. You must NOT use built-in numpy random sampling functions (e.g., np.random.normal) or any other library's direct sampling methods for the distributions. Instead, implement sample generation manually using the underlying principles and basic Python (e.g., random.random(), random.gauss()).

Formulas to Use

Normal distribution PDF:

f(x)=1σ2πe(xμ)22σ2f(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x - \mu)^2}{2\sigma^2}}

Standard deviation from variance:

σ=variance\sigma = \sqrt{\text{variance}}

Binomial distribution PMF:

P(X=k)=(nk)nk(1n)nk,where(nk)=n!k!(nk)!P(X = k) = \begin{pmatrix}n\\k\end{pmatrix}n^k(1-n)^{n-k},\quad \text{where}\begin{pmatrix}n\\k\end{pmatrix} = \frac{n!}{k!(n-k)!}

Uniform distribution PDF:

f(x)=1baforaxbf(x) = \frac{1}{b-a}\quad \text{for}\quad a \le x \le b
Завдання

Swipe to start coding

  1. Complete the starter code below by filling in the blanks (____) using the concepts/formulas above.
  2. Use only random and math modules.
  3. Implement three functions to generate 1000 samples from each distribution (Normal: using random.gauss(); Binomial: simulating n Bernoulli trials; Uniform: scaling random.random()).
  4. Plot histograms for each distribution (plotting code given, just complete the sampling functions and parameters).
  5. Retain all comments exactly as shown, they explain each step.
  6. No use of numpy random functions or external sampling libraries.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

close

Awesome!

Completion rate improved to 1.89
Секція 5. Розділ 12
single

single

some-alt