本文介绍了在R中绘制偏正态分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定案例数,均值,标准差,中位数和 MAD .

How can I plot a skewed normal distribution in R, given the number of cases, the mean, standard deviation, median and the MAD.

一个例子是我有1'196例,平均成本为6'389,标准差为5'158,中位数为4'930,MAD为1'366.而且我们知道,开票案件总是要花一些钱,因此费用必须始终是正数.

A example would be that I have 1'196 cases, were the mean cost is 6'389, the standard deviation 5'158, the median 4'930 and the MAD 1'366. And we know that the billed case always cost something, so the cost must always be positive.

我可以找到的对此问题的最佳答案是来自 https://math.stackexchange.com/a/17995/54064 ,并建议使用 sn 软件包.但是我无法弄清楚如何在我的具体用例中使用它.

The best answer to this problem I could find is from https://math.stackexchange.com/a/17995/54064 and recommends the usage of the sn package. However I could not figure out how to use it for my concrete use case.

推荐答案

我在 fGarch 包中取得了一些成功.

I've had some success with fGarch package.

require("fGarch")
hist(rsnorm(1000, mean = 0, sd = 1, xi = 15))

mmm <- replicate(300, {
  x <- rsnorm(1196, mean = 6389, sd = 5158, xi = 15)
  c(mean = mean(x), sd = sd(x))
})

> mean(mmm[1, ])
[1] 6404.312
> mean(mmm[2, ])
[1] 5169.572

这篇关于在R中绘制偏正态分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 12:56