Related course access:IoT Security and Privacy — same laboratory, notebook and completion record.
M04 · Academic orientation
Scope and objectives
Scope of the experiment
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
The focus of this experiment is to calculate standardized deviations using baseline statistics. Students then trace anomaly scores and threshold decisions, and handle zero variance and distinguish outliers from confirmed faults. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.
Learning objectives
Calculate standardized deviations using baseline statistics.
Trace anomaly scores and threshold decisions.
Handle zero variance and distinguish outliers from confirmed faults.
Identify the configured inputs (Absolute z threshold; Injected fault vibration shift) and record the corresponding observed outputs with units where applicable.
Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.
Expected learning outcomes
On completion, students can calculate standardized deviations using baseline statistics, trace anomaly scores and threshold decisions, and handle zero variance and distinguish outliers from confirmed faults.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing handle zero variance and distinguish outliers from confirmed faults. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to Time-series forecasting & causal windows.
The supplied model, datasets and local Python or Colab notebook. Report the data partition and execution environment; do not claim physical edge-device performance from host measurements.
Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.
M04 · learning outcome
Understand the experiment
Anomaly score · Normal-only reference distribution
Scientific concept map: Normal baseline — Center and spread; New measurement — Shifted input; Anomaly score — Distance from reference; Threshold — Alert or normal; Result — Score and alert.
Scientific foundations and analytical reasoning
Standardized anomaly score z=(x−mean)/std compares a sample to a normal-only reference. Standard deviation convention must be declared.
Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.
Scientific theory · Normal-only anomaly scoring
A standardized score compares a feature to its normal baseline: z=(x−μ)/σ. An absolute-value threshold identifies deviations in either direction when that is the chosen rule. Estimate μ and σ from the training normal data, not anomalous test records. Handle zero variance explicitly.
Worked example and engineering interpretation
With μ=10, σ=2 and x=16, z=3. An absolute threshold of 2 flags this observation. A high score is evidence of deviation, not proof of a specific fault; verify with independent sensor or maintenance evidence.
Engineering principles · additional worked teaching example
A z-score measures distance from a reference mean in standard-deviation units. For μ=20,σ=4, x=30 gives z=2.5; abs(z)>2 flags it. Threshold sign and strictness matter; σ=0 requires explicit handling.
From theory to experiment
Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.
How to investigate Unsupervised anomaly scoring
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.
Experiment-specific guided practice
Objective: Fit a normal-only vibration baseline and detect deviations using a standardized distance.
Set Absolute z threshold = 2; Injected fault vibration shift = 3. Observe the calculated results and trace.
Change Absolute z threshold = 4. Increasing the threshold cannot increase detections with unchanged scores.
Restore the reference values. Record false alarms and missed faults; change the injected shift and describe sensitivity.
Reference check:
Model boundary:
Independent task and submission evidence
2. Change Absolute z threshold = 4. Increasing the threshold cannot increase detections with unchanged scores. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.
Trial
Changed setting
Fixed settings
Predicted result
Actual observation / units
Evidence / uncertainty
A: baseline
Reference
Record
Predict
Record
Record
B: one change
Record
Same as A
Predict
Record
Record
A: repeat
Restore
Same as A
Predict
Record
Record
Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
Method: Absolute z-score from known-normal training subset.
Data provenance: deterministic generated teaching fixture or configured analytical model. No real sensor data, physical inference performance, or production deployment is claimed.
Worked engineering reasoning and boundary conditions
Engineering reference configuration: Absolute z threshold = 2; Injected fault vibration shift = 3. In the classroom model, Training normal rows = 39; False alarms = 0; Recall = 0.9; F1 = 0.947368. A one-feature z-score is a baseline detector, not an attack classifier. Injected shifts are generated, not captured sensor faults. Absolute z-score from known-normal training subset
Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.
Mathematical representation and interpretation
Standardized anomaly score
Use training-normal means and scales. x_i is a feature, mu and sigma its baseline mean and standard deviation. Handle constant features and validate the threshold on independent data.
Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.
Step 1 of 7 · Observation 80
Observation 80
Anomaly score
4.233009
Threshold
2
Observation 86
Anomaly score
0.847623
Threshold
2
Observation 93
Anomaly score
0.7455
Threshold
2
Observation 100
Anomaly score
4.033869
Threshold
2
Observation 106
Anomaly score
0.648483
Threshold
2
Observation 112
Anomaly score
0.250202
Threshold
2
Observation 119
Anomaly score
1.342921
Threshold
2
Teaching example only; inspect live calculations or real practical evidence separately.
Recall the concept before revealing its explanation.
0 / 3 revealed
M04 · 01 / 08What observations define the normal baseline?Reveal explanation
Engineering explanation
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
M04 · 02 / 08What anomaly score is used?Reveal explanation
Engineering explanation
Absolute z-score from known-normal training subset
M04 · 03 / 08What changes when the absolute z threshold rises?Reveal explanation
Engineering explanation
Increasing the threshold cannot increase detections with unchanged scores.
M04 · 04 / 08What does the absolute standardized distance measure?Reveal explanation
Engineering reasoning
The magnitude of deviation from the training normal mean in standard-deviation units.
M04 · 05 / 08Why is an anomaly score not an attack label?Reveal explanation
Engineering reasoning
Unusual measurements can arise from benign changes or faults; identifying cause requires additional evidence.
M04 · 06 / 08A normal-only baseline is used for anomaly scoring. Select every technically valid statement.
A. Estimate baseline parameters from normal training observations.
B. A high standardized deviation may be flagged under the chosen rule.
C. Fit the normal baseline with every future anomalous observation.
D. A high score proves a specific attack cause.Reveal explanation
Applied scenario
Correct: A. Estimate baseline parameters from normal training observations.; B. A high standardized deviation may be flagged under the chosen rule.
M04 · 07 / 08In Unsupervised anomaly scoring, which reference and changed settings are prescribed for Absolute z threshold?Reveal explanation
Controlled configuration
Absolute z threshold: 2 → 4; hold the remaining settings fixed.
M04 · 08 / 08What expected result distinguishes the reference and changed trials in Unsupervised anomaly scoring?Reveal explanation
Expected observation
Increasing the threshold cannot increase detections with unchanged scores.
Loading live engineering instrument…Supplementary research apparatusLoading experiment-specific apparatus…Scientific model · primary investigation
Simulation task
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.
Interactive engineering workbenchM04 · Scientific model
Readout from the original computational model; not physical measurements.
Loading instrument…
Awaiting model display.
Experimental instrumentation · A/B
Compare two model conditions
Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.
Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.
Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.
Prepare a contextual AI prompt
0 characters
Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.
Prepare → review → copy & open your selected provider → paste and submit there.
Independent theoretical exercises
Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.
01 · Predict and derive using the given inputs
For mean=10 and std=2, calculate z for 9,14,15,6. Flag absolute z>2 and compare ≥2.
Engineering method — A z-score measures distance from a reference mean in standard-deviation units. For μ=20,σ=4, x=30 gives z=2.5; abs(z)>2 flags it. Threshold sign and strictness matter; σ=0 requires explicit handling. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Explain effect of fitting the baseline on fault-containing samples and distinguish anomalies from verified faults.
Engineering method — A z-score measures distance from a reference mean in standard-deviation units. For μ=20,σ=4, x=30 gives z=2.5; abs(z)>2 flags it. Threshold sign and strictness matter; σ=0 requires explicit handling. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Boundary calculation
Boundary calculation · Independent work
Reference μ=50,σ=5; observations40,41,60,61. Flag under abs(z)>2 and abs(z)≥2.
Boundary calculation — A z-score measures distance from a reference mean in standard-deviation units. For μ=20,σ=4, x=30 gives z=2.5; abs(z)>2 flags it. Threshold sign and strictness matter; σ=0 requires explicit handling. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.
Expanded independent theoretical exercise bank
Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.
Intermediate · Explain a changed-input result
Independent theoretical exercise · M04-01
Use the reference configuration (Absolute z threshold = 2; Injected fault vibration shift = 3), but change Absolute z threshold = 1.8. The model reports Recall = 0.95. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Quantitative comparison
Independent theoretical exercise · M04-02
Two model observations of Recall are 0.9 (reference) and 0.95 (changed condition). Compute signed change and, when the reference is nonzero, percentage change. Explain why units matter.
Intermediate · Interpret a technical trace
Independent theoretical exercise · M04-03
For Injected fault vibration shift = 3.2, the model supplies this excerpt from Calculated trace:
Item · Value · Explanation
Normal mean · 2.348718 ·
Normal std · 1.004317 ·
Missed faults · 1 ·
Compute the range (maximum minus minimum) of the Value column in these rows. Identify the maximum observation. Do not extrapolate beyond these rows.
Advanced · Reverse reasoning
Independent theoretical exercise · M04-04
An observation is Recall = 0.95. Candidate A uses Absolute z threshold = 2; Injected fault vibration shift = 3. Candidate B changes the listed settings (Injected fault vibration shift = 3.2) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.
Advanced · Diagnose a reported mismatch
Independent theoretical exercise · M04-05
A student configures Absolute z threshold = 4 while preserving all other reference settings, but copies the reference report of Recall = 0.9. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · M04-06
Design a controlled comparison for Unsupervised anomaly scoring using reference Absolute z threshold = 2; Injected fault vibration shift = 3 and test Absolute z threshold = 1.8. Specify the changed setting(s), measured metric Recall, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
1 · Reference workbench configuration
Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.
Absolute z threshold2
Injected fault vibration shift3
2 · Perform the investigation in order
Set Absolute z threshold = 2; Injected fault vibration shift = 3. Observe the calculated results and trace.
Change Absolute z threshold = 4. Increasing the threshold cannot increase detections with unchanged scores.
Restore the reference values. Record false alarms and missed faults; change the injected shift and describe sensitivity.
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
Reference
Use reference inputs above
Increasing the threshold cannot increase detections with unchanged scores.
Record actual result
Controlled change
Absolute z threshold = 4
Increasing the threshold cannot increase detections with unchanged scores.
Record actual result
4 · Analyze and report
Record false alarms and missed faults; change the injected shift and describe sensitivity.
Required evidence: Record the unsupervised anomaly scoring comparison and justify the changed outcome from the calculated trace.
Model boundary: Absolute z-score from known-normal training subset
Controlled investigation · reproducible evidence
Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.
Trial
Independent change
Dependent observation
Reference
Use reference inputs above
Record actual outcome and units
Controlled change
Absolute z threshold = 4
Record actual outcome and units
Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.
Loading laboratory-specific procedure…
Python / Google Colab notebook
Original Python reference, generated teaching fixture. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
Keep the fault vibration shift at 3 and the threshold at 2. Run 40 samples and record the normal training mean, score and detection counts.
Reset and repeat at threshold 4 with the same fault shift. Compute recall and false-alarm rate from the confusion matrix.
Reset to threshold 2 and vary injected shift. Compare the distribution of anomaly scores against the threshold.
Explain the limitations of a single-feature detector; verify the reference configuration with Python.
Evidence: retain your prediction, configuration, observations and exported event history; distinguish calculated teaching-model results from physical measurements.
Complete practical procedure & acceptance
Read the method, enter a prediction and save the reference baseline.
Apply the controlled change and compare metrics and plot. Record false alarms and missed faults; change the injected shift and describe sensitivity.
Restore the reference and verify that the original metrics return. Enter an invalid parameter and confirm that export is disabled, then restore.
Run the independent local Python computation from the extracted portal root:
BASH · Command
python3 verification/ml168_practical.py all
Expected: ten passing checks and a result object for each lab. This uses Python standard library only. Compare the default result for M04 to the browser output.
Export actual observations and explain one limitation.
Student submission: include your prediction, exported baseline and controlled result, actual terminal output, and a short interpretation. Do not submit the build validation report as your own evidence.
Experimental notebook
Record your own results. Values are not prefilled or independently verified.
Record & discuss
Portfolio exports use related core lab K14 for compatibility. The supplementary experiment ID is preserved in the attachment. Local completion is self-reported.
Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.
Execution scope: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# m04 · Unsupervised anomaly scoring
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
## How to run
1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook.
2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all.
3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell.
4. Save your own outputs and compare them to the portal Experiment tab.
**Execution boundary:** Original Python reference, generated teaching fixture. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation
Fit a normal-only vibration baseline and detect deviations using a standardized distance.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Set Absolute z threshold = 2; Injected fault vibration shift = 3. Observe the calculated results and trace.
2. Change Absolute z threshold = 4. Increasing the threshold cannot increase detections with unchanged scores.
3. Restore the reference values. Record false alarms and missed faults; change the injected shift and describe sensitivity.
**Evidence:**
**Boundary:**
03Instructions · Markdown
## 1. Objectives and reference condition
- Reproduce the specific computational mechanism in this laboratory.
- Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy.
- Distinguish actual local Python execution from mock, physical and external-service observations.
## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# M04 | Code cell 01 | Unsupervised anomaly scoring
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
## 3. Implementation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# M04 | Code cell 02 | Unsupervised anomaly scoring
# Purpose: implement only the mechanism named in this laboratory.
# Inputs: the explicit fictional fixture and reference parameters below.
# Output: printed observations and assertions for the controlled trial.
# =====================================================================
import statistics as st
def fixture():
rows=[]
for i in range(120):
x=18+(i*7%23)+((i*13%9)-4)/10; v=1+(i*11%17)/5
rows.append(dict(id=i,device=f'node-{1+i//40}',x=x,v=v,y=2.1*x+3+((i*19%13)-6)*.4,fault=int(x+3*v+((i*17%11)-5)/2>36)))
return rows
def matrix(y,p):
tp=sum(a==b==1 for a,b in zip(y,p)); tn=sum(a==b==0 for a,b in zip(y,p)); fp=sum(a==0 and b==1 for a,b in zip(y,p)); fn=sum(a==1 and b==0 for a,b in zip(y,p)); ratio=lambda a,b:a/b if b else 0
return dict(tp=tp,tn=tn,fp=fp,fn=fn,accuracy=ratio(tp+tn,len(y)),precision=ratio(tp,tp+fp),recall=ratio(tp,tp+fn),f1=ratio(2*tp,2*tp+fp+fn))
rows=fixture();train,test=rows[:80],rows[80:]
normal=[r['v'] for r in train if not r['fault']];mu=st.mean(normal);sd=st.pstdev(normal)
# Absolute z score relative to normal reference observations.
y=[r['fault'] for r in test];scores=[abs((r['v']+3*r['fault']-mu)/sd) for r in test]
### Step 2 · Run the reference calculation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
08Python · executable cell
PYTHON · Code cell
# =====================================================================
# M04 | Code cell 03 | Unsupervised anomaly scoring
# Purpose: implement only the mechanism named in this laboratory.
# Inputs: the explicit fictional fixture and reference parameters below.
# Output: printed observations and assertions for the controlled trial.
# =====================================================================
low=matrix(y,[int(s>=2) for s in scores]);high=matrix(y,[int(s>=4) for s in scores]);print('2 sigma',low,'4 sigma',high)
assert high['tp']+high['fp']<=low['tp']+low['fp']
## Original portal implementation (reference only)
These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all.
```bash
python3 verification/ml168_practical.py all
```
10Instructions · Markdown
## 4. Results and analysis
Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result.
| Trial | Configuration | Observation | Interpretation |
|---|---|---|---|
| A | Reference | | |
| B | One controlled change | | |
| C | Reference repeat | | |
**Limitations:** Original Python reference, generated teaching fixture. Notebook success does not certify external equipment or services.
11Instructions · Markdown
## Guided reasoning and evidence
A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above.
**Independent task:** 2. Change Absolute z threshold = 4. Increasing the threshold cannot increase detections with unchanged scores. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
| Trial | Input/configuration | Prediction | Observation | Evidence / limitation |
|---|---|---|---|---|
| A | Reference | | | |
| B | Changed input | | | |
| A repeat | Reference | | | |
A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research