text stringlengths 0 828 |
|---|
Additional Parameters |
---------------------- |
{0} |
"""""" |
return _make_rank(self, n, mu, sigma, crit=crit, upper=upper, |
xtol=xtol)" |
3895,"def fit_mle(self, data, b=None): |
""""""%(super)s |
Additional Parameters |
---------------------- |
b : float |
The upper limit of the distribution |
"""""" |
# Take mean of data as MLE of distribution mean, then calculate p |
mu = np.mean(data) |
if not b: |
b = np.sum(data) |
lam = _expon_solve_lam_from_mu_vect(mu, b) |
# Just return float, not len 1 array |
if len(np.atleast_1d(lam)) == 1: |
return float(lam), b |
else: |
return lam, b" |
3896,"def fit_mle(self, data, fix_mean=False): |
""""""%(super)s |
Additional Parameters |
---------------------- |
fix_mean : bool |
Default False. If True, fixes mean before optimizing sigma |
"""""" |
if not fix_mean: |
sigma, _, scale = stats.lognorm.fit(data, floc=0) |
return np.log(scale), sigma |
else: |
mean = np.mean(data) |
# MLE fxn to be optmimized |
mle = lambda sigma, x, mean: -1 *\ |
np.sum(self._pdf_w_mean(x, mean, sigma)) |
sigma = optim.fmin(mle, np.array([np.std(np.log(data), ddof=1)]), |
args=(data, mean), disp=0)[0] |
return self.translate_args(mean, sigma)" |
3897,"def _pdf_w_mean(self, x, mean, sigma): |
"""""" |
Calculates the pdf of a lognormal distribution with parameters mean |
and sigma |
Parameters |
---------- |
mean : float or ndarray |
Mean of the lognormal distribution |
sigma : float or ndarray |
Sigma parameter of the lognormal distribution |
Returns |
------- |
: float or ndarray |
pdf of x |
"""""" |
# Lognorm pmf with mean for optimization |
mu, sigma = self.translate_args(mean, sigma) |
return self.logpdf(x, mu, sigma)" |
3898,"def union_join(left, right, left_as='left', right_as='right'): |
"""""" |
Join function truest to the SQL style join. Merges both objects together in a sum-type, |
saving references to each parent in ``left`` and ``right`` attributes. |
>>> Dog = namedtuple('Dog', ['name', 'woof', 'weight']) |
>>> dog = Dog('gatsby', 'Ruff!', 15) |
>>> Cat = namedtuple('Cat', ['name', 'meow', 'weight']) |
>>> cat = Cat('pleo', 'roooowwwr', 12) |
>>> catdog = union_join(cat, dog, 'cat', 'dog') |
>>> catdog.name |
pleo |
>>> catdog.woof |
Ruff! |
>>> catdog.dog.name |
gatsby |
:param left: left object to be joined with right |
:param right: right object to be joined with left |
:return: joined object with attrs/methods from both parents available |
"""""" |
attrs = {} |
attrs.update(get_object_attrs(right)) |
attrs.update(get_object_attrs(left)) |
attrs[left_as] = left |
attrs[right_as] = right |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.