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

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.

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 5. Capitolo 12
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

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

Scorri per mostrare il 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
Compito

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.

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

close

Awesome!

Completion rate improved to 1.89
Sezione 5. Capitolo 12
single

single

some-alt