def likelihood(mcmc, position):
     mcmc.simulate(position=position)
     #sigma = mcmc.cur_params(position)[-1]
     nbd = mcmc.solver.yexpr['NBD']
     # The value of 0.085 for the SD was obtained by examining the residuals
     # at a maximum posterior fit
     err = np.sum((mcmc.data - nbd)**2 / (2 * 0.085 ** 2))
     #err = np.sum((mcmc.data - nbd)**2 / (2 * sigma ** 2))
     return err
 def likelihood(mcmc, position):
     mcmc.simulate(position=position)
     #sigma = mcmc.cur_params(position)[-1]
     nbd = mcmc.solver.yexpr['NBD']
     dr = mcmc.solver.yexpr['Tb']
     dr_sd = mcmc.dr_data * 0.03
     nbd_sd = mcmc.nbd_data * 0.03
     err = np.sum((mcmc.nbd_data - nbd)**2 / (2 * nbd_sd ** 2)) + \
           np.sum((mcmc.dr_data - dr)**2 / (2 * dr_sd ** 2))
     #err = np.sum((mcmc.dr_data - dr)**2 / (2 * dr_sd ** 2))
     return err
Exemple #3
0
 def likelihood(mcmc, position):
     yout = mcmc.simulate(position, observables=True)
     # TODO Need to be able to get the indices from the model so that
     # they're not hardcoded
     params = mcmc.cur_params(position)
     err = 0
     for data_index, obs_name in zip(data_indices, self.nbd_observables):
         timecourse = ((yout[obs_name] /
                        mcmc.options.model.parameters['Bax_0'].value)
                       * params[3])
         err += np.sum((self.nbd_avgs[data_index] - timecourse)**2 /
                          (2 * self.nbd_stds[data_index]**2))
     return err
Exemple #4
0
    def likelihood(mcmc, position):
        """The likelihood function."""
        err = 0
        for bax_conc in mcmc.data.columns:
            # Get the data for this concentration
            tc = mcmc.data[bax_conc]
            y_data  = np.array(tc[:,'MEAN'])
            time = np.array(tc[:,'TIME'])
            mcmc.solver.tspan = time # set the time span

            # Get the simulated data for this concentration
            mcmc.options.model.parameters['Bax_0'].value = bax_conc
            x = mcmc.simulate(position=position, observables=True)
            avg_pores = x['pores']/ \
                        mcmc.options.model.parameters['Vesicles_0'].value
            y_mod = 1 - np.exp(-avg_pores)

            # Calculate the error, accounting for the SD at this
            # concentration.
            # Skip the first timepoint--the SD is 0 (due to normalization)
            # and hence gives nan when calculating the error.
            err += np.sum(((y_data[1:] - y_mod[1:])**2) / \
                    (2 * (np.array(tc[:,'SD'][1:]) ** 2)))
        return err
 def likelihood(mcmc, position):
     mcmc.simulate(position=position)
     nbd = mcmc.solver.yexpr['NBD']
     err = np.sum((mcmc.data - nbd)**2 / (2 * ((0.02 * mcmc.data)**2)))
     return err