**UPDATE 1/15/2014**: This blog is no longer in service.

This post is now located at: http://slendermeans.org/ml4h-ch2-p2.html

Thanks,

-c.

Advertisements

I'd like to drop my trousers to the world. I am a man of means, of slender means.

**UPDATE 1/15/2014**: This blog is no longer in service.

This post is now located at: http://slendermeans.org/ml4h-ch2-p2.html

Thanks,

-c.

Advertisements

This entry was posted in Data Analysis, Will it Python and tagged machine learning, python, R. Bookmark the permalink.

%d bloggers like this:

Pingback: Will it Python? ARM Chapter 5: Logistic models of well-switching in Bangladesh | Slender Means

You asked for interface to allow single decile to be passed to function without needing to put it in iterable. You can utilize variable number of arguments and let it do the building of the tuple for you:

# Function to get arbitrary quantiles of a series.

def my_quantiles(s, *prob):

'''

Calculate quantiles of a series.

Parameters:

-----------

s : a pandas Series

prob : a tuple (or other iterable) of probabilities at

which to compute quantiles. Must be an iterable,

even for a single probability (e.g. prob = (0.50)

not prob = 0.50).

Returns:

--------

A pandas series with the probabilities as an index.

'''

prob = prob or (0.0, 0.25, 0.5, 1.0)

q = [s.quantile(p) for p in prob]

return Series(q, index = prob)

`# With single prob argument`

print my_quantiles(heights, .10)

Comments are not updated, they were also in error in that singleton tuple containing 0.50 is (0.50,) Parenthesis are sometimes not needed. Looks like the code tag destroyed indent, I do not know how I should have posted it with indentation intact.

Thanks, Tony. That’s clever. I was not really adept at using argument unpacking when I wrote that post.