Git Product home page Git Product logo

Comments (7)

Stefan-Heimersheim avatar Stefan-Heimersheim commented on August 28, 2024

Hi Vivian,

this sounds like you just want to manually add a likelihood, so you have to add another likelihood to your cobaya dictionary

sampler['likelihood'] = {
                    'theta_star_likelihood': {
                    'external': theta_star_gaussian,
                    },
                    # other likelihoods ...

with some Gaussian

def theta_star_gaussian(theta_star):
     return scipy.stats.norm.logpdf(...)

I think there is also an even shorter way without defining the external function but the key is adding the Gaussian to your likelihoods.

Cheers,
Stefan

PS: Name of function and likelihood is not important, just the argument of the likelihood function has to match your parameter.

from cobaya.

vivianmiranda avatar vivianmiranda commented on August 28, 2024

Thank you.

Sorry for the delay. I was in the DES meeting in the UK (super busy)

Will this work even if I am not sampling on \theta? I am sampling on H0 instead and I can't change that because my work is in the context of DES. That has been my problem - how to find \theta variable when I am sampling H0.

from cobaya.

Stefan-Heimersheim avatar Stefan-Heimersheim commented on August 28, 2024

Hmm, I see the problem and I can't find a solution in this case.

It should be possible to get theta (probably 100*theta_s or theta_s_1e2) out of classy and use it for the likelihood. In the cobaya documentation here it says any param that CLASS understands but I don't know how to do that, especially because 100*theta_s is a terrible variable name ...

Edit: If the parameter is added to the params block it should be available to the custom likelihood as well.

Edit2: Oh, I was thinking you are using CLASS. The variable name for CAMB is different as Antony pointed out

from cobaya.

cmbant avatar cmbant commented on August 28, 2024

Does it not work by making a new likelihood as Jesus suggested in #18? "thetastar" is a standard CAMB derived parameter so you should be able to get it from _theory (and then rescale?).

If it doesn't work a simple toy example yaml/.py to reproduce the issue might be helpful - we are working on some significant internal changes at the moment that may make more general dependencies possible and useful to have test cases.

from cobaya.

vivianmiranda avatar vivianmiranda commented on August 28, 2024

I see, Thank you. @JesusTorrado @cmbant any idea on how I can do this?

from cobaya.

cmbant avatar cmbant commented on August 28, 2024

I haven't tried but as above but with something like this (assuming CAMB)?

def theta_star_gaussian(_theory={'thetastar'}):
     thetastar = _theory.get_param('thetastar')
    . ...

(or maybe "cosmomc_theta")

from cobaya.

vivianmiranda avatar vivianmiranda commented on August 28, 2024

Thank you

like_theta: "lambda _theory={'thetastar': None}: stats.norm.logpdf(_theory.get_param('thetastar'),loc=1.04092,scale=0.0031)"

worked. I was misspelling the thetastar variable (I was including an _ in between) before. You are all the best!

from cobaya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.