【问题标题】:Compute the Full Width at Half Maximum (FWHM) for the 2 modes of a bimodal distribution计算双峰分布的 2 种模式的半峰全宽 (FWHM)
【发布时间】:2021-08-16 09:10:13
【问题描述】:

在堆栈溢出问题上潜伏多年后,我终于发布了我的第一个问题,因为我找不到描述我的问题的帖子。

对于项目的一个方面,我绘制了数据框 (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
    )
})

plot generated by above code

现在我需要做的是估计每种模式的计数。我的计划是计算每种模式的半高全宽 (FWHM),获取范围并找出范围内的计数。

我尝试应用我在此处 (Finding the full width half maximum of a peak) 看到的内容,但这似乎不适用于 R,也不适用于此处 (Determining the FWHM from a distribution in R),但在后者中,它适用于单峰分布。

我的感觉是,我可以在上面编写的 mapply 函数中应用一些函数,该函数可以像在 Determining the FWHM from a distribution in R 中一样计算 FWHM,但我所有的尝试都失败了。

有什么建议吗?

谢谢你,我希望这篇文章很清楚。抱歉,如果没有,我是一个溢出口香糖。

【问题讨论】:

    标签: r histogram normal-distribution


    【解决方案1】:

    你可能想多了。 lambda(1-lambda) 估计您的数据属于每种模式的比例。

    【讨论】:

      【解决方案2】:

      我明白了,尤其是如果我有兴趣报告一个比率。我会这样做的,谢谢。

      但是我仍然会好奇如何做我最初打算为未来可能的目的做的事情:--)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-05-25
        • 1970-01-01
        • 2015-02-09
        • 2014-01-15
        • 2011-07-23
        • 1970-01-01
        • 2012-07-16
        • 1970-01-01
        相关资源
        最近更新 更多