weecology / macroecotools

Tools for Macroecological Analyses Using Python
Other
9 stars 13 forks source link

get_rad_from_cdf function #14

Closed klocey closed 4 months ago

klocey commented 9 years ago

Why does the function get_rad_from_cdf(cdf, S) have nothing in it other than a docstring? This should be fine, right?

def get_rad_from_cdf(ad):

    p = md.zipf_solver(ad)
    S = len(ad)

    rv = stats.zipf(a=p)

    rad = []
    for i in range(1, S+1):
        val = (S - i + 0.5)/S
        x = rv.ppf(val)
        rad.append(int(x))

    return rad
rueuntal commented 9 years ago

@ethanwhite please correct me if I'm wrong - I think what we had in mind was a general function that would give the RAD for a variety of different distributions, which never got written. If you only need the RAD for Zipf distribution though, your code looks good to me. Ethan, shall we remove this function or get down and work it out?

klocey commented 9 years ago

@ethanwhite @rueuntal I think what we had in mind was a general function that would give the RAD for a variety of different distributions, which never got written.

This is what I figured. Made sense.

ethanwhite commented 9 years ago

@rueuntal - that is what I was envisioning. If it's easy to write the generic form that would be great. I had stubbed it in at some point and never gotten back to it.

rueuntal commented 9 years ago

@klocey @ethanwhite I've made an attempt, please let me know if anything doesn't look right. The code that Ken has in mind can be written as get_rad_from_cdf(stats.zipf, S, p).

ethanwhite commented 9 years ago

This looks good to me from a quick read. @klocey - can you test this and see if it's giving you the expected results?