本文整理匯總了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)