Testing
AuraScore 81/100

Metamorphic Test Suite Script for Bayesian Inference Pipelines

Develop a metamorphic statistical test script to detect sampling drift, distribution collapse, and algorithmic bias.

Use this template when setting up automated regression and statistical validation tests for stochastic algorithms, MCMC samplers, and Bayesian models. It outputs a script utilizing two-sample statistical tests on metamorphic transformations.

Template

Role: Lead Machine Learning QA Architect specializing in Probabilistic Systems and Statistical Inference.

Context

  • Inference algorithm under test: {{inference_algorithm}}
  • Metamorphic relations to test: {{metamorphic_relations}}
  • Input distribution specification: {{input_distribution_spec}}
  • Prior distribution rules: {{prior_distribution_rules}}
  • Statistical significance threshold: {{drift_significance_level}}
  • Target runtime platform: {{runtime_platform_runtime}}

Task

Author an end-to-end metamorphic testing and statistical assertion script in {{runtime_platform_runtime}} to detect algorithmic regression, numerical drift, and sampling distribution collapse in complex probabilistic models.

Method

  1. Parse the expected behavior of {{inference_algorithm}} alongside its baseline distribution constraints.
  2. Generate synthetic test datasets conforming to {{input_distribution_spec}} using deterministic pseudo-random seeds.
  3. Apply metamorphic transformations defined in {{metamorphic_relations}} (e.g., affine scaling, label permutations, coordinate shifts).
  4. Execute inference across base and transformed datasets, recording posterior parameter estimates.
  5. Implement two-sample statistical hypothesis tests (e.g., Kolmogorov-Smirnov, Wasserstein distance) calibrated to {{drift_significance_level}}.
  6. Validate that posterior outputs respect constraints from {{prior_distribution_rules}}.
  7. Implement failure diagnostics that output quantile-quantile comparisons and divergence metrics when tests reject the null hypothesis.

Constraints

  • The script MUST be written as a self-contained, runnable test suite for {{runtime_platform_runtime}}.
  • Statistical assertions MUST NOT use fixed threshold comparisons for stochastic outputs; two-sample statistical tests are required.
  • Execution MUST emit standardized test output with significance p-values and effect sizes.
  • Every metamorphic relation MUST have an explicit deterministic baseline and transformation function.

Output format

Provide a complete executable script containing:

  1. Dataset Synthesis and Metamorphic Transformation Helpers
  2. Probabilistic Oracle and Statistical Test Assertion Classes
  3. Parametrized Test Suite Execution Runner
  4. Divergence Metric Logging and Structured Report Exporter

Self-review

  • Confirm {{inference_algorithm}} output distributions are validated using valid statistical hypothesis tests.
  • Verify {{metamorphic_relations}} transformations preserve expected mathematical invariants.
  • Ensure execution does not depend on non-deterministic unseeded random states.
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-testing
complex-reasoning-analysis-math
metamorphic-testing
bayesian-inference
statistical-testing