handley-lab/fgivenx

handling a piecewise function

Closed this issue · 4 comments

Please describe how to deal with a piecewise function in fgivenx. Thanks.

Hi @surgithub. Could you give me a bit more detail about how you've currently tried to do this? One way to implement a vectorisable piecewise function is using a numpy.where construction:

def f(x, theta):
    m0, c0, m1, c1 = theta
    y = np.where(x<0, m0*x + c0, m1*x + c1)
    return y

would implement a function that is piecewise linear either side of zero, but without more detail about the kind of piecewise function you're trying to implement I'm not sure if this is what you're looking for.

It is working now. Thank you. One more point: How to ignore the initial rows from the samples, or is there any command in fgivenx to remove initial fraction of samples, something like the following command of getdist
settings={'ignore_rows':0.3}

OK, I have now updated the samples_from_getdist_chains so that it can take settings={'ignore_rows':0.3} as an argument (and indeed any keyword that you would usually pass to loadMCSamples. This has also been updated on pypi.

Thank you.