当前位置: 首页>>代码示例>>Python>>正文


Python FieldArray.from_arrays方法代码示例

本文整理汇总了Python中pycbc.io.FieldArray.from_arrays方法的典型用法代码示例。如果您正苦于以下问题:Python FieldArray.from_arrays方法的具体用法?Python FieldArray.from_arrays怎么用?Python FieldArray.from_arrays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycbc.io.FieldArray的用法示例。


在下文中一共展示了FieldArray.from_arrays方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prior_rvs

# 需要导入模块: from pycbc.io import FieldArray [as 别名]
# 或者: from pycbc.io.FieldArray import from_arrays [as 别名]
    def prior_rvs(self, size=1, prior=None):
        """Returns random variates drawn from the prior.

        If the ``sampling_args`` are different from the ``variable_args``, the
        variates are transformed to the `sampling_args` parameter space before
        being returned.

        Parameters
        ----------
        size : int, optional
            Number of random values to return for each parameter. Default is 1.
        prior : JointDistribution, optional
            Use the given prior to draw values rather than the saved prior.

        Returns
        -------
        FieldArray
            A field array of the random values.
        """
        # draw values from the prior
        if prior is None:
            prior = self._prior
        p0 = prior.rvs(size=size)
        # transform if necessary
        if self._sampling_transforms is not None:
            ptrans = self.apply_sampling_transforms(p0)
            # pull out the sampling args
            p0 = FieldArray.from_arrays([ptrans[arg]
                                         for arg in self._sampling_args],
                                        names=self._sampling_args)
        return p0
开发者ID:spxiwh,项目名称:pycbc,代码行数:33,代码来源:likelihood.py

示例2: samples

# 需要导入模块: from pycbc.io import FieldArray [as 别名]
# 或者: from pycbc.io.FieldArray import from_arrays [as 别名]
    def samples(self):
        """Returns the samples in the chain as a FieldArray.

        If the sampling args are not the same as the variable args, the
        returned samples will have both the sampling and the variable args.

        The returned FieldArray has dimension [additional dimensions x]
        nwalkers x niterations.
        """
        # chain is a [additional dimensions x] niterations x ndim array
        samples = self.chain
        sampling_args = self.sampling_args
        # convert to dictionary to apply boundary conditions
        samples = {param: samples[...,ii]
                   for ii,param in enumerate(sampling_args)}
        samples = self.likelihood_evaluator._prior.apply_boundary_conditions(
            **samples)
        # now convert to field array
        samples = FieldArray.from_arrays([samples[param]
                                          for param in sampling_args],
                                         names=sampling_args)
        # apply transforms to go to variable args space
        return self.likelihood_evaluator.apply_sampling_transforms(samples,
            inverse=True)
开发者ID:cmbiwer,项目名称:pycbc,代码行数:26,代码来源:sampler_base.py


注:本文中的pycbc.io.FieldArray.from_arrays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。