Challenge: 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).
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)=σ2π1e−2σ2(x−μ)2Standard deviation from variance:
σ=varianceBinomial distribution PMF:
P(X=k)=(nk)nk(1−n)n−k,where(nk)=k!(n−k)!n!Uniform distribution PDF:
f(x)=b−a1fora≤x≤bSwipe to start coding
- Complete the starter code below by filling in the blanks (
____
) using the concepts/formulas above. - Use only
random
andmath
modules. - Implement three functions to generate 1000 samples from each distribution (Normal: using
random.gauss()
; Binomial: simulating n Bernoulli trials; Uniform: scalingrandom.random()
). - Plot histograms for each distribution (plotting code given, just complete the sampling functions and parameters).
- Retain all comments exactly as shown, they explain each step.
- No use of
numpy
random functions or external sampling libraries.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
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?
Awesome!
Completion rate improved to 1.89
Challenge: Quality Control Sampling
Veeg om het menu te tonen
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).
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)=σ2π1e−2σ2(x−μ)2Standard deviation from variance:
σ=varianceBinomial distribution PMF:
P(X=k)=(nk)nk(1−n)n−k,where(nk)=k!(n−k)!n!Uniform distribution PDF:
f(x)=b−a1fora≤x≤bSwipe to start coding
- Complete the starter code below by filling in the blanks (
____
) using the concepts/formulas above. - Use only
random
andmath
modules. - Implement three functions to generate 1000 samples from each distribution (Normal: using
random.gauss()
; Binomial: simulating n Bernoulli trials; Uniform: scalingrandom.random()
). - Plot histograms for each distribution (plotting code given, just complete the sampling functions and parameters).
- Retain all comments exactly as shown, they explain each step.
- No use of
numpy
random functions or external sampling libraries.
Oplossing
Bedankt voor je feedback!
Awesome!
Completion rate improved to 1.89single