在堆栈溢出上潜伏了多年之后,我终于发布了我的第一个问题,因为我找不到一篇描述我的问题的文章。
对于项目的一个方面,我绘制了包含在dataframe (df)中的参数(方向)的分布图,以发现它采用双峰分布。我在这里展示"2.7“样本的数据:
A tibble: 5,280 x 13
ID number_of_points length bend average_curvatu~ relative_z_chan~ average_z_height orientation Depth Scale AspectR
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 14-3~ 935 940. 1.33 177. 0.291 171. 154. 0.35 6 2.7
2 14-3~ 629 629. 1.07 235. 0.346 467. 29.2 0.35 6 2.7
3 14-3~ 550 562. 1.18 159. 0.402 286. 22.5 0.35 6 2.7
4 14-3~ 334 334. 1.03 322. 0.507 444. 37 0.35 6 2.7
5 14-3~ 397 397. 1.01 292. 0.484 415. 16.4 0.35 6 2.7
6 14-3~ 1132 1135. 1.06 246. 0.301 401. 31.1 0.35 6 2.7
7 14-3~ 1169 1175. 1.14 179. 0.255 370. 11.9 0.35 6 2.7
8 14-3~ 1363 1366. 1.04 273. 0.183 383. 23.1 0.35 6 2.7
9 14-3~ 841 843. 1.09 274. 0.310 307. 21.5 0.35 6 2.7
10 14-3~ 881 883. 1.16 210. 0.226 451. 164. 0.35 6 2.7
# ... with 5,270 more rows, and 2 more variables: Circularity <dbl>, lam <chr>利用normalmixEM可以确定模拟双峰分布的2高斯分布的参数。
my_mix <- mixtools::normalmixEM(df$orientation, lambda = NULL, mu = NULL, sigma = NULL, maxit = 5000)我能够提取曲线的mu、sigma和lambda参数,并将它们存储到一个表中(FIT)。以下是样本“2.7”的两种模式参数:
A tibble: 10 x 5
ID lambda mu sigma AspectR
<chr> <dbl> <dbl> <dbl> <dbl>
1 2.7 0.723 38.5 22.8 2.7
2 2.7 0.277 150. 20.2 2.7 通过运行以下代码,我能够生成一个具有直方图和2高斯覆盖的图形:
p <- ggplot(df$orientation, aes(x = orientation)) +
geom_histogram(binwidth = 5) +
mapply(
function(mean, sd, lambda, n, binwidth){
stat_function(
fun = function(x){
(dnorm(x, mean = mean, sd = sd)) * n * binwidth * lambda
}
)
},
mean = FIT$mu,
sd = FIT$sigma,
lambda = FIT$lambda,
n = length(df$orientation),
binwidth = 5
)
})现在我需要做的是估计每一种模式中的计数。我的计划是计算每一种模式的半最大宽度(FWHM),得到范围并找出范围内的计数。
我尝试应用我在这里看到的(求峰值的全宽半最大值),但这似乎不是为R,也不是在这里(R中分布的半高宽的确定),但在后者,它是一个单峰分布。
我的感觉是,我可能能够在上面写的may函数中应用一些函数,它可以像在R中分布的半高宽的确定中那样计算FWHM,但我的所有尝试都失败了。
有什么建议吗?
谢谢,我希望这篇文章是清楚的。抱歉,如果没有,我是一个溢出的甘比。
将要
发布于 2021-05-28 06:22:51
你可能想得太多了。lambda和(1-lambda)给出了属于每种模式的数据比例的估计。
发布于 2021-05-28 16:22:23
我认为是的,特别是如果我对报告比率感兴趣的话。谢谢你我会这么做的。
然而,我仍然会好奇如何做我原本打算为未来的潜在目的:-)。
https://stackoverflow.com/questions/67733452
复制相似问题