How to use the jupyter.Timo.own.mfl_sensing_simplelib.ExpDecoKnownPrecessionModel function in jupyter

To help you get started, we’ve selected a few jupyter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ulm-IQO / qudi / jupyter / Timo / own / mfl_sensing_simplelib.py View on Github external
pr0 = np.zeros((modelparams.shape[0], expparams.shape[0]))
        pr0[:, :] = z

        return self.pr0_to_likelihood_array(outcomes, pr0)

    def add_noise(self, z):
        import random
        noisy_z = z + np.random.normal(loc=0, scale=1. / np.sqrt(4 * self.c_eff ** 2 * self.n_rep))  # Degen 17 (eqn 37)

        return noisy_z, z

    def sample(self, z, n_samples=1e3):
        return np.random.normal(loc=z, scale=1. / np.sqrt(4 * self.c_eff ** 2 * self.n_rep), size=int(n_samples))


class NoisyPoissonianExpDecoKnownPrecessionModel(ExpDecoKnownPrecessionModel):
    def __init__(self, min_freq=0.0, max_freq=1.0, invT2=0, cts_0=0.04, cts_1=0.03, n_rep=1e6):
        """
        :param min_freq:
        :param max_freq:
        :param invT2:
        :param cts_0: counts per laser shot in |0>
        :param cts_1: counts per laser shot in |1>
        :param n_rep: (=n_sweeps) number of Ramsey reptitions per epoch
        """
        super().__init__(min_freq, invT2)

        self.cts_0 = cts_0
        self.cts_1 = cts_1
        self.n_rep = n_rep  # number of experimental repetitions

    def likelihood(self, outcomes, modelparams, expparams, noisy=False, res_no_noise=None):
github Ulm-IQO / qudi / jupyter / Timo / own / mfl_sensing_simplelib.py View on Github external
track_cov[idx_experiment] = np.sqrt(self.updater.est_covariance_mtx())
            if verbose: print("New cov: ", track_cov[idx_experiment])

        if verbose: print('\nFinal estimate is: ' + str(self.updater.est_mean()[0]))
        if verbose: print('##########################\n')

        return [np.array(track_eval), track_loss, track_cov, track_acctime, track_pgh_time, track_time]


##################################################
# Ulm extensions (Timo)
##################################################


class NoisyGaussianExpDecoKnownPrecessionModel(ExpDecoKnownPrecessionModel):
    def __init__(self, min_freq=0.0, max_freq=1.0, invT2=0, c_eff=1, n_rep=1e6):
        super().__init__(min_freq, invT2)

        self.c_eff = c_eff  # readout efficiency parameter c
        self.n_rep = n_rep  # number of experimental repetitions

    def likelihood(self, outcomes, modelparams, expparams, noisy=False, res_no_noise=None):

        p = super().likelihood(outcomes, modelparams, expparams)
        if not noisy:
            return p

        if p.shape != (2, 1, 1):
            raise NotImplementedError("NoisyGaussian only implemented for 1d model. Shape: {}".format(p.shape))
        z = p[0, 0, 0]  # value of interet
        z, z_real = self.add_noise(z)
github Ulm-IQO / qudi / jupyter / Timo / own / mfl_sensing_simplelib.py View on Github external
def __init__(self, min_freq=0.0, max_freq=1.0, invT2=0, noise="Absent", eta=1.0):

        # super().__init__(min_freq, invT2)
        base_model = ExpDecoKnownPrecessionModel(min_freq=min_freq, invT2=invT2)

        if noise is "Absent":
            self.model = base_model
        elif noise is "Binomial":
            self.model = qi.BinomialModel(base_model)
        elif noise is "Unbalanced":
            self.model = qi.BinomialModel(AsymmetricLossModel(base_model, eta=eta))
github Ulm-IQO / qudi / jupyter / Timo / own / mfl_sensing_simplelib.py View on Github external
def __init__(self, freq_min=0.0, freq_max=1.0, n_particles=1000, noise="Absent", eta=1.0):

        base_model = ExpDecoKnownPrecessionModel(min_freq=freq_min)

        if noise is "Absent":
            self.model = base_model
        elif noise is "Binomial":
            self.model = qi.BinomialModel(base_model)
        elif noise is "Unbalanced":
            self.model = qi.BinomialModel(AsymmetricLossModel(base_model, eta=eta))

        self.n_particles = n_particles

        self.freq_min = freq_min
        self.freq_max = freq_max

        self.fft_est = None
        self.bay_est = None
github Ulm-IQO / qudi / jupyter / Timo / own / mfl_sensing_simplelib.py View on Github external
def __init__(self, min_freq=0, invT2=0., eta_assym=1, read_phase=0.0):
        super(ExpDecoKnownPrecessionModel, self).__init__()

        self._min_freq = min_freq
        self._invT2 = invT2
        if eta_assym is None:
            eta_assym = 1
        self._eta_assym = eta_assym
        self._read_phase = read_phase

        # Initialize a default scale matrix.
        self._Q = np.ones((self.n_modelparams,))