Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende 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
Tarea

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.

Solución

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 5. Capítulo 12
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

close

Awesome!

Completion rate improved to 1.89

bookChallenge: Quality Control Sampling

Desliza para mostrar el menú

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
Tarea

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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

close

Awesome!

Completion rate improved to 1.89
Sección 5. Capítulo 12
single

single

some-alt