Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Allocating first serves to make sure that a shape mismatch later
# will cause an error.
pr0 = np.zeros((modelparams.shape[0], expparams.shape[0]))
pr0[:, :] = 0.5 * (np.cos(t * modelparams[:, 0] / 2) ** 2 + np.cos(t * modelparams[:, 1] / 2) ** 2)[
..., np.newaxis]
# print("Pr0 = " + str(pr0) )
# Now we concatenate over outcomes.
# print("likelihoods: " + str(qi.FiniteOutcomeModel.pr0_to_likelihood_array(outcomes, pr0)))
return qi.FiniteOutcomeModel.pr0_to_likelihood_array(outcomes, pr0)
class ExpDecoKnownMultimodePrecModel(MultimodePrecModel):
def __init__(self, min_freq=0, inv_T2=0.):
super().__init__()
self._min_freq = min_freq
self._invT2 = inv_T2
def likelihood(self, outcomes, modelparams, expparams):
"""
:param np.ndarray outcomes: set of possible experimental outcomes (here [0,1])
:param np.ndarray modelparams: Set of model parameter vectors to be
updated.
:param np.ndarray expparams: An experiment parameter array describing
the experiment that was just performed.
:param numpy.ndarray: likelihoods of obtaining outcome ``0`` from each
def likelihood(self, outcomes, modelparams, expparams):
# By calling the superclass implementation, we can consolidate
# call counting there.
super(MultimodePrecModel, self).likelihood(
outcomes, modelparams, expparams
)
# print('outcomes = ' + repr(outcomes))
# Possibly add a second axis to modelparams.
if len(modelparams.shape) == 1:
modelparams = modelparams[..., np.newaxis]
# print('modelparams = ' + repr(modelparams))
# print('expparams = ' + repr(expparams))
# print('m = ' + str(modelparams))
# print('w_ = ' + str(expparams['w_']))
t = expparams['t']
# print('dw=' + repr(dw))