[Scipy-svn] r2432 - trunk/Lib/sandbox/models
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Dec 17 19:26:11 EST 2006
Author: timl
Date: 2006-12-17 18:26:07 -0600 (Sun, 17 Dec 2006)
New Revision: 2432
Modified:
trunk/Lib/sandbox/models/mixed.py
Log:
simplify some expressions
Modified: trunk/Lib/sandbox/models/mixed.py
===================================================================
--- trunk/Lib/sandbox/models/mixed.py 2006-12-18 00:25:20 UTC (rev 2431)
+++ trunk/Lib/sandbox/models/mixed.py 2006-12-18 00:26:07 UTC (rev 2432)
@@ -181,12 +181,12 @@
"""
- S = 0
- Y = 0
for unit in self.units:
unit.fit(self.a, self.D, self.sigma)
- S += unit.compute_xtwx()
- Y += unit.compute_xtwy()
+
+ S = sum([unit.compute_xtwx() for unit in self.units])
+ Y = sum([unit.compute_xtwy() for unit in self.units])
+
self.Sinv = L.pinv(S)
self.a = N.dot(self.Sinv, Y)
@@ -258,12 +258,8 @@
return logL
def initialize(self):
- S = 0
- Y = 0
- for unit in self.units:
- S += N.dot(unit.X.T, unit.X)
- Y += N.dot(unit.X.T, unit.Y)
-
+ S = sum([N.dot(unit.X.T, unit.X) for unit in self.units])
+ Y = sum([N.dot(unit.X.T, unit.Y) for unit in self.units])
self.a = L.lstsq(S, Y)[0]
D = 0
@@ -328,8 +324,9 @@
m = Mixed(units, response, fixed, random)
m.initialize()
m.fit()
- print m.a
+
+
## a = Unit()
## a['x'] = N.array([2,3])
## a['y'] = N.array([3,4])
More information about the Scipy-svn
mailing list