Пример #1
0
    def carmapack_to_params(self, pc):
        p = self.to_params(np.zeros(self.nparams))

        mu = pc[2]
        nu = np.sqrt(pc[1])
        sigma = pc[0]

        p['logit_mu'] = par.bounded_params(mu,
                                           low=self.mu_min,
                                           high=self.mu_max)
        p['logit_sigma'] = par.bounded_params(sigma,
                                              low=self.sigma_min,
                                              high=self.sigma_max)
        p['logit_nu'] = par.bounded_params(nu,
                                           low=self.nu_min,
                                           high=self.nu_max)

        p['ar_roots_p'] = par.stable_polynomial_params(
            self._quad_to_roots(pc[3:3 + self.p]))

        if self.q >= 1:
            p['ma_roots_p'] = par.stable_polynomial_params(
                self._quad_to_roots(pc[3 + self.p:]))

        return p
Пример #2
0
def guess_planet_params(P0, K, T):
    K = K*(1.0 + 1e-3*np.random.randn()) # part in 10^3
    P = P0*(1.0 + 1e-3*np.random.randn()) # part in 10^3
    e = np.random.uniform(low=0, high=0.1)
    omega = np.random.uniform(low=0, high=2*np.pi)
    chi = np.random.uniform(low=0, high=1)

    return np.array([np.log(K),
                     par.bounded_params(P, low=0, high=T),
                     par.bounded_params(e, low=0, high=1),
                     par.bounded_params(omega, low=0, high=2*np.pi),
                     par.bounded_params(chi, low=0, high=1)])
Пример #3
0
def guess_planet_params(P0, K, T):
    K = K * (1.0 + 1e-3 * np.random.randn())  # part in 10^3
    P = P0 * (1.0 + 1e-3 * np.random.randn())  # part in 10^3
    e = np.random.uniform(low=0, high=0.1)
    omega = np.random.uniform(low=0, high=2 * np.pi)
    chi = np.random.uniform(low=0, high=1)

    return np.array([
        np.log(K),
        par.bounded_params(P, low=0, high=T),
        par.bounded_params(e, low=0, high=1),
        par.bounded_params(omega, low=0, high=2 * np.pi),
        par.bounded_params(chi, low=0, high=1)
    ])
Пример #4
0
    def kep_fixed_deparameterize(self, kps):
        kps_ext = np.zeros((kps.shape[0], 5))

        kps_ext[:, 0] = kps[:, 0]
        kps_ext[:, 1] = par.bounded_params(self.Pfixed, low=0, high=self.T)
        kps_ext[:, 2:] = kps[:, 1:]

        return self.kep_deparameterize(kps_ext)
Пример #5
0
    def kep_fixed_deparameterize(self, kps):
        kps_ext = np.zeros((kps.shape[0], 5))

        kps_ext[:,0] = kps[:,0]
        kps_ext[:,1] = par.bounded_params(self.Pfixed, low=0, high=self.T)
        kps_ext[:,2:] = kps[:,1:]

        return self.kep_deparameterize(kps_ext)
Пример #6
0
    def draw_prior(self):
        mu = np.random.uniform(low=self.mu_min, high=self.mu_max)
        sigma = np.exp(
            np.random.uniform(low=np.log(self.sigma_min),
                              high=np.log(self.sigma_max)))
        nu = np.exp(
            np.random.uniform(low=np.log(self.nu_min),
                              high=np.log(self.nu_max)))
        ar_quad = self._roots_to_quad(self.draw_roots(self.p))
        ma_quad = self._roots_to_quad(self.draw_roots(self.q))

        mup = par.bounded_params(mu, low=self.mu_min, high=self.mu_max)
        sigmap = par.bounded_params(sigma,
                                    low=self.sigma_min,
                                    high=self.sigma_max)
        nup = par.bounded_params(nu, low=self.nu_min, high=self.nu_max)

        return np.concatenate((mup, sigmap, nup, ar_quad, ma_quad))
Пример #7
0
    def parameterize(self, mu, sigma, nu, ar_roots, ma_roots=None):
        p = self.to_params(np.zeros(self.nparams))

        p['logit_mu'] = par.bounded_params(mu,
                                           low=self.mu_min,
                                           high=self.mu_max)
        p['logit_sigma'] = par.bounded_params(sigma,
                                              low=self.sigma_min,
                                              high=self.sigma_max)
        p['logit_nu'] = par.bounded_params(nu,
                                           low=self.nu_min,
                                           high=self.nu_max)

        p['ar_roots_p'] = par.stable_polynomial_params(ar_roots, self.root_min,
                                                       self.root_max)
        if ma_roots is not None:
            p['ma_roots_p'] = par.stable_polynomial_params(
                ma_roots, self.root_min, self.root_max)

        return p