本文整理汇总了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
示例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)