首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >pyhf:统计不确定性的实现

pyhf:统计不确定性的实现
EN

Stack Overflow用户
提问于 2020-08-04 17:03:34
回答 1查看 187关注 0票数 2

关于统计不确定性的实施,我有一个问题。在pyhf文档https://scikit-hep.org/pyhf/likelihood.html#sample中,您提到了推断统计不确定性的方法是使用带有"type":"staterror“和data field=0.1的修饰符。

所以让我们假设我有一个来自MC的背景频道,我把我的发行分成三个回收箱:

代码语言:javascript
复制
"name": "background",
"data": [300., 50., 60.]

你如何正确地解释统计不确定性?从Poissonian的构建,我想说,通过建设,你已经考虑了统计的不确定性。还是我必须有一个包含状态错误的修饰符?统计错误的数据字段到底是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-06 04:48:05

I有一个来自MC的背景频道

考虑到由于Monte样本大小有限,您想要对形状的不确定性进行建模,最好使用的修改器是staterrorstaterror在所有样本(有一个staterror修饰符)之间共享,它是在正常约束下应用的,约束的强度是在正交中添加的每个样本的不确定性。在这里,data键表示样本中每个桶中的绝对不确定性(在本例中是bin计数的泊松不确定性):

因此,考虑到一个带有3个回收箱的单个背景示例,示例规范可能如下所示(我将命名为bkg_only_spec.json)。

代码语言:javascript
复制
{
    "channels": [
        {
            "name": "single_channel",
            "samples": [
                {
                    "name": "background",
                    "data": [
                        300.0,
                        50.0,
                        60.0
                    ],
                    "modifiers": [
                        {
                            "name": "uncorr_bkguncrt",
                            "type": "staterror",
                            "data": [
                                17.32051,
                                7.07107,
                                7.74597
                            ]
                        }
                    ]
                }
            ]
        }
    ],
    "observations": [
        {
            "name": "single_channel",
            "data": [
                300.0,
                50.0,
                60.0
            ]
        }
    ],
    "measurements": [
        {
            "name": "Measurement",
            "config": {
                "poi": "mu",
                "parameters": []
            }
        }
    ],
    "version": "1.0.0"
}

我们可以看到(注意,constrained_by_normal)仍然是CLI's inspect的一个有效规范(当然,您也需要一个信号样本来进行任何推断)

代码语言:javascript
复制
$ pyhf --version
pyhf, version 0.5.1
$ python answer.py
$ pyhf inspect bkg_only_spec.json
          Summary       
    ------------------  
       channels  1
        samples  1
     parameters  1
      modifiers  1

       channels  nbins
     ----------  -----
 single_channel    3  

        samples
     ----------
     background

     parameters  constraint              modifiers
     ----------  ----------              ----------
uncorr_bkguncrt  constrained_by_normal   staterror

    measurement           poi            parameters
     ----------        ----------        ----------
(*) Measurement            mu            (none)

下面的answer.py生成规范。

代码语言:javascript
复制
# answer.py
import numpy as np
import json


def main():
    bins = [300.0, 50.0, 60.0]
    # rounding, as keeping full floating point is maybe a bit silly
    poisson_uncert = np.sqrt(bins).round(decimals=5).tolist()

    # just set the observations to be the same as the bin count here
    # as a placeholder
    spec = {
        "channels": [
            {
                "name": "single_channel",
                "samples": [
                    {
                        "name": "background",
                        "data": bins,
                        "modifiers": [
                            {
                                "name": "uncorr_bkguncrt",
                                "type": "staterror",
                                "data": poisson_uncert,
                            }
                        ],
                    }
                ],
            }
        ],
        "observations": [{"name": "single_channel", "data": bins}],
        "measurements": [
            {"name": "Measurement", "config": {"poi": "mu", "parameters": []}}
        ],
        "version": "1.0.0",
    }

    with open("bkg_only_spec.json", "w") as spec_file:
        json.dump(spec, spec_file, indent=4)


if __name__ == "__main__":
    main()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63251753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档