Skip to content

Commit

Permalink
Removed von Mises constraint
Browse files Browse the repository at this point in the history
git-svn-id: https://pymc.googlecode.com/svn/trunk@1162 15d7aa0b-6f1a-0410-991a-d59f85d14984
  • Loading branch information
anand.prabhakar.patil committed Jan 15, 2009
1 parent 2f8023e commit 26b3444
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 26 deletions.
8 changes: 4 additions & 4 deletions code_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ def remove_whitespace(fname):
for line in lines:
fd.write(line+'\n')
fd.close()
print 'Removed whitespace from %s'%fname
# print 'Removed whitespace from %s'%fname

print
# print

# ====================
# = Strip whitespace =
# ====================
for dirname, dirs, files in os.walk('.'):
if dirname[1:].find('.')==-1:
print dirname
# print dirname
for fname in files:
if fname[-2:] in ['c', 'f'] or fname[-3:]=='.py' or fname[-4:] in ['.pyx', '.txt', '.tex', '.sty', '.cls'] or fname.find('.')==-1:
print fname
# print fname
remove_whitespace(dirname + '/' + fname)

# ==========================
Expand Down
16 changes: 8 additions & 8 deletions pymc/CommonDeterministics.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,12 @@ def coef(index=self.index, x=x):
def pfunc(func):
"""
pf = pfunc(func)
Returns a function that can be called just like func; however its arguments may be
PyMC objects or containers of PyMC objects, and its return value will be a deterministic.
Example:
>>> A = pymc.Normal('A',0,1,size=10)
>>> pprod = pymc.pfunc(numpy.prod)
>>> B = pprod(A, axis=0)
Expand All @@ -442,7 +442,7 @@ def dtrm_generator(*args, **kwds):
parents[fargs[i]] = args[i]
else:
varargs.append(args[i])

if len(varargs)==0:
eval_fun = func
else:
Expand All @@ -455,13 +455,13 @@ def wrapper(**wkwds_in):
wargs.extend(wkwds.pop('varargs'))
return func(*wargs, **wkwds)
eval_fun = wrapper

return pm.Deterministic(eval_fun, doc_str, name, parents, trace=False, plot=False)
dtrm_generator.__name__ = func.__name__ + '_deterministic_generator'
dtrm_generator.__doc__ = """
Deterministic-generating wrapper for %s. Original docstring:
%s
%s
"""%(func.__name__, '_'*60, func.__doc__)
return dtrm_generator
Expand Down Expand Up @@ -531,8 +531,8 @@ def eval_fun(self, other, op, rt_op):
# Convert the functions into methods for klass.
new_method.__name__ = '__'+prefix+op_name+'__'
setattr(klass, new_method.__name__, UnboundMethodType(new_method, None, klass))


def create_rl_lin_comb_method(op_name, klass, x_roles, y_roles):
"""
Creates a new binary special method with left and right versions, such as
Expand Down
4 changes: 1 addition & 3 deletions pymc/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1943,12 +1943,10 @@ def von_mises_like(x, mu, kappa):
.. math::
f(x \mid \mu, k) = \\frac{{e}^{k \\operatorname{cos}\\left(x - u\\right)}}{2 \\pi I0(k)}
\mu-\pi<= x <=mu+pi
:Parameters:
x : float
Input data. Must be between mu-pi and mu+pi
Input data.
mu : float
Mean of the distribution.
kappa : float
Expand Down
5 changes: 1 addition & 4 deletions pymc/examples/model_1_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ def r(s=s, e=e, l=l):
out[s:] = l
return out

<<<<<<< .mine

# Where the mask is true, the value is taken as missing.
masked_data = np.ma.masked_array(disasters_array, disasters_mask)
D = ImputeMissing('D', Poisson, masked_data, mu=r)
=======
# Where the value is -999, the datum is assumed to be missing.
D = Impute('D', Poisson, disasters_array, missing=-999, mu=r)>>>>>>> .r1155
9 changes: 2 additions & 7 deletions pymc/flib.f
Original file line number Diff line number Diff line change
Expand Up @@ -2879,7 +2879,7 @@ SUBROUTINE vonmises(x,mu,kappa,n,nmu, nkappa, like)
DOUBLE PRECISION like
DOUBLE PRECISION tmp
DOUBLE PRECISION x(n),mu(nmu),kappa(nkappa)
DOUBLE PRECISION mu_tmp, kappa_tmp, dev
DOUBLE PRECISION mu_tmp, kappa_tmp
LOGICAL not_scalar_mu, not_scalar_kappa
DOUBLE PRECISION PI
PARAMETER (PI=3.141592653589793238462643d0)
Expand All @@ -2897,17 +2897,12 @@ SUBROUTINE vonmises(x,mu,kappa,n,nmu, nkappa, like)
do i=1,n
if (not_scalar_mu) mu_tmp=mu(i)
if (not_scalar_kappa) kappa_tmp=kappa(i)
dev = dabs(x(i)-mu_tmp)
if (dev .GT. PI) then
like = -infinity
RETURN
endif
if (kappa_tmp .LT. 0.0) then
like = -infinity
RETURN
endif
like = like - dlog(2*PI*i0(kappa_tmp))
like = like + kappa_tmp*dcos(dev)
like = like + kappa_tmp*dcos(x(i)-mu_tmp)
enddo
return
END

0 comments on commit 26b3444

Please sign in to comment.