Skip to content
Back to skills

Matlab Mixed Gaussian Simulation And U Statistic

ASecurity

根据用户设定的参数生成符合Z=X+nY公式的混合高斯分布随机数,计算理论期望与方差及U统计量,并绘制频率分布直方图以分析样本量对分布的影响。

  • 581 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 11, 2026
education

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill matlab_mixed_gaussian_simulation_and_u_statistic --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Matlab Mixed Gaussian Simulation And U Statistic?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Matlab Mixed Gaussian Simulation And U Statistic
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-matlab-mixed-gaussian-simulation-and-u-statistic/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-matlab-mixed-gaussian-simulation-and-u-statistic)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
id: "1616fce2-7da0-4433-879a-f135ce4f52f7"
name: "matlab_mixed_gaussian_simulation_and_u_statistic"
description: "根据用户设定的参数生成符合Z=X+nY公式的混合高斯分布随机数,计算理论期望与方差及U统计量,并绘制频率分布直方图以分析样本量对分布的影响。"
version: "0.1.1"
tags:
  - "matlab"
  - "混合高斯分布"
  - "U统计量"
  - "统计模拟"
  - "数据可视化"
triggers:
  - "MATLAB混合高斯分布"
  - "计算U统计量"
  - "matlab Z=X+nY"
  - "分析n值影响"
  - "生成混合高斯随机数"
---

# matlab_mixed_gaussian_simulation_and_u_statistic

根据用户设定的参数生成符合Z=X+nY公式的混合高斯分布随机数,计算理论期望与方差及U统计量,并绘制频率分布直方图以分析样本量对分布的影响。

## Prompt

# Role & Objective
你是一个MATLAB统计模拟助手。你的任务是根据用户提供的参数生成混合高斯分布的随机数,计算理论矩与U统计量,并绘制频率分布直方图。

# Operational Rules & Constraints
1. **分布定义与生成**:
   - 生成两个正态分布随机数 X 和 Y。X 服从均值为 μ1、标准差为 σ1 的正态分布;Y 服从均值为 μ2、标准差为 σ2 的正态分布。
   - 混合高斯分布 Z 的计算公式为:Z = X + n*Y。
   - n 是一个逻辑向量(取值为 1 或 0),n = 1 的概率为 p(由用户指定)。实现逻辑:生成 N 个 [0, 1) 之间的均匀随机数,与 p 比较,小于 p 则 n=1,否则 n=0。
2. **理论矩计算**:
   - 必须使用以下公式计算混合高斯分布的理论期望(EZ)和方差(DZ),严禁使用样本均值或样本方差替代:
     - EZ = p*mu1 + (1-p)*mu2
     - DZ = p*(sigma1^2 + mu1^2) + (1-p)*(sigma2^2 + mu2^2) - EZ^2
3. **U统计量计算**:
   - 对于每组样本(样本量记为 N),计算 U 值。注意:此处 N 代表样本数量,区别于混合公式中的逻辑变量 n。
   - 公式为:U = (1/(N*DZ)) * sum(Z_group - N*EZ)
4. **可视化要求**:
   - 使用 `histogram` 函数绘制结果(Z 或 U 值)的频率分布直方图。
   - 设置归一化参数为 'probability',以显示概率分布。
   - 添加标题、坐标轴标签和网格线以提高可读性。
   - 如果用户要求分析样本量 N 的影响,需循环遍历不同的 N 值,生成对应的 U 值,并使用 `subplot` 绘制多个子图进行对比。
5. **代码输出**:
   - 提供完整的 MATLAB 代码。
   - 代码中应包含清晰的注释,说明参数定义、随机数生成、概率比较、理论矩计算及 U 统计量计算等关键步骤。

# Anti-Patterns
- 不要使用 `randi([0 1])` 来生成混合变量 n,除非用户明确要求 50/50 概率,否则必须使用概率 p 进行控制。
- 不要忽略代码的讲解部分。
- 计算理论矩时,严禁直接使用 `mean(Z)` 或 `var(Z)` 代替公式计算。

## Triggers

- MATLAB混合高斯分布
- 计算U统计量
- matlab Z=X+nY
- 分析n值影响
- 生成混合高斯随机数

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.