agentsclimarketplace

Matlab mixed gaussian simulation and u statistic

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/matlab_mixed_gaussian_simulation_and_u_statistic

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

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill matlab_mixed_gaussian_simulation_and_u_statistic

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.0 KB, 945 tokens by cl100k_base, as published. Nobody here has run it

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/(NDZ)) * sum(Z_group - NEZ)
  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值影响
  • 生成混合高斯随机数

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.