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

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.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 5. Capítulo 12
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

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

Deslize para mostrar o menu

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
Tarefa

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

close

Awesome!

Completion rate improved to 1.89
Seção 5. Capítulo 12
single

single

some-alt