Example #1
0
    def numerator_integrand(r):

        out = np.zeros_like(r)
        vesc = m.vesc_model(r,0.,0.,params,model)
        out[vesc<=v] = 0.
        out[vesc>v] = (m.vesc_model(r[vesc>v],0.,0.,params,model) - v)**(k+1.) * spline(r[vesc>v])
        return out
Example #2
0
def outlier_probabilities(params, data, vmin, model):

    """
    Likelihood function template for given model. 

    Arguments
    ---------

    params: array_like
        the model parameters

    data: list
        the output of sample_distances_multiple_tracers

    vmin: float 
        the minimum radial velocity considered 

    Returns
    -------

    logL: array_like
        the sum of the log-likelihoods for this set of parameters.
    """

    kbhb,kkgiant,kms,f = params[:4]
    pot_params = params[4:]
    outlier_probabilities = [None,None,None]
    k = [kbhb,kkgiant,kms]
    outlier_normalisation = ( .5*m.erfc( vmin / (np.sqrt(2.)*1000.) ) )**-1.

    for i,tracer in enumerate(data):
        l,b,v,s = tracer
        x,y,z = gu.galactic2cartesian(s,b,l)
        vesc = m.vesc_model(x,y,z,pot_params,model)
        out = np.zeros_like(v)
        with m.warnings.catch_warnings():
            #deliberately getting NaNs here so stop python from telling us about it
            m.warnings.simplefilter("ignore",category=RuntimeWarning)
            out = (1.-f)*(k[i]+2)*(vesc - np.abs(v))**(k[i]+1.) / (vesc - vmin)**(k[i]+2.) + \
                        f*outlier_normalisation*m.Gaussian(np.abs(v),0.,1000.)
            out[np.isnan(out)] = f*outlier_normalisation*m.Gaussian(np.abs(v[np.isnan(out)]),0.,1000.)
            outlier = f*outlier_normalisation*m.Gaussian(np.abs(v),0.,1000.)
        outlier_probabilities[i] = np.mean(outlier,axis=1) / np.mean(out, axis=1)

    return outlier_probabilities
Example #3
0
    def denominator_integrand(r):

        return spline(r)*(m.vesc_model(r,0.,0.,params,model) - vmin)**(k+2.) / (k+2.)
Example #4
0
 def m_vesc(r, params):
     return -m.vesc_model(r, 0., 0., params, model)
Example #5
0
 def vesc(r, params):
     return m.vesc_model(r, 0., 0., params, model)