summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Green <ben@SEASITs-MacBook-Pro.local>2015-06-16 00:38:40 -0400
committerBen Green <ben@SEASITs-MacBook-Pro.local>2015-06-16 00:38:40 -0400
commit289cc934a3e4c130563538a462e0cd32a08b0256 (patch)
treea1159e3c7437e60c45ec47090234f54ce5143de1
parentf7997e0c67ea85b42da94894b6a6f9bef7382170 (diff)
downloadcriminal_cascades-289cc934a3e4c130563538a462e0cd32a08b0256.tar.gz
Changed model for spawning. Began fixing underflow error in
prob_success/failure
-rw-r--r--experiments/build/temp.macosx-10.6-x86_64-2.7/ml.obin311532 -> 297088 bytes
-rw-r--r--experiments/build_network.py6
-rw-r--r--experiments/ml.c1363
-rw-r--r--experiments/ml.pyx86
-rwxr-xr-xexperiments/ml.sobin109364 -> 108528 bytes
-rw-r--r--experiments/out.log150
-rw-r--r--experiments/process.py9
7 files changed, 579 insertions, 1035 deletions
diff --git a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o
index 42c7292..6235b48 100644
--- a/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o
+++ b/experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o
Binary files differ
diff --git a/experiments/build_network.py b/experiments/build_network.py
index fd7179f..0756ded 100644
--- a/experiments/build_network.py
+++ b/experiments/build_network.py
@@ -7,7 +7,7 @@ from os.path import splitext
def build_network(filename):
victims = {}
non_victims = {}
- age = 0.
+ age = 0
with open(filename) as fh:
reader = DictReader(fh)
for row in reader:
@@ -15,7 +15,7 @@ def build_network(filename):
dist = int(row["dist"])
w1, w2, w3 = float(row["w1"]), float(row["w2"]), float(row["w3"])
# if int(float(row["dist"])) > 1:
- # continue
+ # continue
# 'to' is a victim
if row["t2"] != "NA":
dt = int(row["t2"]) - int(row["t1"])
@@ -43,6 +43,7 @@ def build_network(filename):
if not victims[victim]:
del victims[victim]
root_victims[victim] = []
+ print len(root_victims), len(victims), len(non_victims)
return root_victims, victims, non_victims, age
@@ -53,5 +54,4 @@ if __name__ == "__main__":
filename = sys.argv[1]
root, _ = splitext(filename)
root_victims, victims, non_victims, age = build_network(filename)
- print age
dump((root_victims, victims, non_victims, age), open(root + ".pickle", "w"))
diff --git a/experiments/ml.c b/experiments/ml.c
index 1bc0ddb..b7bbed6 100644
--- a/experiments/ml.c
+++ b/experiments/ml.c
@@ -759,7 +759,7 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
*/
typedef npy_cdouble __pyx_t_5numpy_complex_t;
-/* "ml.pyx":56
+/* "ml.pyx":34
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
@@ -773,7 +773,7 @@ struct __pyx_obj_2ml___pyx_scope_struct__ml {
};
-/* "ml.pyx":80
+/* "ml.pyx":58
* for (dist, dt, w1, w2, w3) in parents]
* # find parent that maximizes log(p) - log(\tilde{p})
* probs[i] = max(s - failures[l] for l, s in enumerate(successes)) # <<<<<<<<<<<<<<
@@ -971,7 +971,17 @@ static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
#endif
#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
-static void __Pyx_RaiseBufferFallbackError(void);
+static double __Pyx__PyObject_AsDouble(PyObject* obj);
+#if CYTHON_COMPILING_IN_PYPY
+#define __Pyx_PyObject_AsDouble(obj) \
+(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \
+ likely(PyInt_CheckExact(obj)) ? \
+ PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
+#else
+#define __Pyx_PyObject_AsDouble(obj) \
+((likely(PyFloat_CheckExact(obj))) ? \
+ PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
+#endif
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
@@ -1050,14 +1060,6 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-static int __Pyx_Print(PyObject*, PyObject *, int);
-#if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
-static PyObject* __pyx_print = 0;
-static PyObject* __pyx_print_kwargs = 0;
-#endif
-
-static int __Pyx_PrintOne(PyObject* stream, PyObject *o);
-
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#define __Pyx_CREAL(z) ((z).real())
@@ -1257,7 +1259,7 @@ static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_pf_2ml_2ml_genexpr(PyObject *__pyx_self); /* proto */
-static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_root_victims, PyObject *__pyx_v_victims, PyObject *__pyx_v_non_victims, __pyx_t_2ml_DTYPE_t __pyx_v_age, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta); /* proto */
+static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_root_victims, PyObject *__pyx_v_victims, PyObject *__pyx_v_non_victims, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_age, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_tp_new_2ml___pyx_scope_struct__ml(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
@@ -1288,17 +1290,14 @@ static char __pyx_k_w1[] = "w1";
static char __pyx_k_w2[] = "w2";
static char __pyx_k_w3[] = "w3";
static char __pyx_k_age[] = "age";
-static char __pyx_k_end[] = "end";
+static char __pyx_k_inf[] = "-inf";
static char __pyx_k_max[] = "max";
static char __pyx_k_sum[] = "sum";
static char __pyx_k_args[] = "args";
static char __pyx_k_beta[] = "beta";
-static char __pyx_k_cums[] = "cums";
static char __pyx_k_dist[] = "dist";
-static char __pyx_k_file[] = "file";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_send[] = "send";
-static char __pyx_k_sort[] = "sort";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_DTYPE[] = "DTYPE";
static char __pyx_k_alpha[] = "alpha";
@@ -1306,16 +1305,15 @@ static char __pyx_k_beta2[] = "beta2";
static char __pyx_k_close[] = "close";
static char __pyx_k_delta[] = "delta";
static char __pyx_k_dtype[] = "dtype";
+static char __pyx_k_max_i[] = "max_i";
static char __pyx_k_numpy[] = "numpy";
-static char __pyx_k_print[] = "print";
static char __pyx_k_probs[] = "probs";
static char __pyx_k_range[] = "range";
static char __pyx_k_roots[] = "roots";
static char __pyx_k_throw[] = "throw";
static char __pyx_k_zeros[] = "zeros";
-static char __pyx_k_cumsum[] = "cumsum";
-static char __pyx_k_format[] = "format";
static char __pyx_k_import[] = "__import__";
+static char __pyx_k_thresh[] = "thresh";
static char __pyx_k_xrange[] = "xrange";
static char __pyx_k_float64[] = "float64";
static char __pyx_k_genexpr[] = "genexpr";
@@ -1323,6 +1321,7 @@ static char __pyx_k_n_nodes[] = "n_nodes";
static char __pyx_k_n_roots[] = "n_roots";
static char __pyx_k_parents[] = "parents";
static char __pyx_k_victims[] = "victims";
+static char __pyx_k_beta_add[] = "beta_add";
static char __pyx_k_failures[] = "failures";
static char __pyx_k_probs_nv[] = "probs_nv";
static char __pyx_k_enumerate[] = "enumerate";
@@ -1333,6 +1332,7 @@ static char __pyx_k_itervalues[] = "itervalues";
static char __pyx_k_probs_fail[] = "probs_fail";
static char __pyx_k_non_victims[] = "non_victims";
static char __pyx_k_RuntimeError[] = "RuntimeError";
+static char __pyx_k_max_beta_add[] = "max_beta_add";
static char __pyx_k_root_victims[] = "root_victims";
static char __pyx_k_ml_locals_genexpr[] = "ml.<locals>.genexpr";
static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
@@ -1340,7 +1340,6 @@ static char __pyx_k_Users_ben_Documents_Cascade_Pro[] = "/Users/ben/Documents/Ca
static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
-static char __pyx_k_alpha_0_delta_1_Everyone_is_a_ro[] = "alpha: {0}, delta: {1}. Everyone is a root";
static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_n_s_DTYPE;
@@ -1352,31 +1351,29 @@ static PyObject *__pyx_kp_s_Users_ben_Documents_Cascade_Pro;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_n_s_age;
static PyObject *__pyx_n_s_alpha;
-static PyObject *__pyx_kp_s_alpha_0_delta_1_Everyone_is_a_ro;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_beta;
static PyObject *__pyx_n_s_beta2;
+static PyObject *__pyx_n_s_beta_add;
static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_cums;
-static PyObject *__pyx_n_s_cumsum;
static PyObject *__pyx_n_s_delta;
static PyObject *__pyx_n_s_dist;
static PyObject *__pyx_n_s_dt;
static PyObject *__pyx_n_s_dtype;
-static PyObject *__pyx_n_s_end;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_failures;
-static PyObject *__pyx_n_s_file;
static PyObject *__pyx_n_s_float64;
-static PyObject *__pyx_n_s_format;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_s_import;
+static PyObject *__pyx_kp_s_inf;
static PyObject *__pyx_n_s_itervalues;
static PyObject *__pyx_n_s_l;
static PyObject *__pyx_n_s_ll;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_max;
+static PyObject *__pyx_n_s_max_beta_add;
+static PyObject *__pyx_n_s_max_i;
static PyObject *__pyx_n_s_ml;
static PyObject *__pyx_n_s_ml_locals_genexpr;
static PyObject *__pyx_n_s_n_nodes;
@@ -1388,7 +1385,6 @@ static PyObject *__pyx_n_s_non_victims;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_n_s_parents;
-static PyObject *__pyx_n_s_print;
static PyObject *__pyx_n_s_probs;
static PyObject *__pyx_n_s_probs_fail;
static PyObject *__pyx_n_s_probs_nv;
@@ -1396,11 +1392,11 @@ static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_root_victims;
static PyObject *__pyx_n_s_roots;
static PyObject *__pyx_n_s_send;
-static PyObject *__pyx_n_s_sort;
static PyObject *__pyx_n_s_successes;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_t;
static PyObject *__pyx_n_s_test;
+static PyObject *__pyx_n_s_thresh;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_victims;
@@ -1410,15 +1406,14 @@ static PyObject *__pyx_n_s_w3;
static PyObject *__pyx_n_s_xrange;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_int_neg_1;
-static PyObject *__pyx_slice_;
+static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__8;
-static PyObject *__pyx_codeobj__9;
+static PyObject *__pyx_codeobj__8;
/* "ml.pyx":9
* ctypedef np.float_t DTYPE_t
@@ -1476,36 +1471,36 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int __pyx_v_dist, int __py
/* "ml.pyx":16
* """weight for successful infection, exponential time model"""
* cdef DTYPE_t structural, temporal, result
- * structural = delta ** (dist) # <<<<<<<<<<<<<<
+ * structural = dist * log(delta) # <<<<<<<<<<<<<<
* # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = exp(-alpha * dt) * (1 - exp(-alpha))
+ * temporal = log(alpha) - alpha * dt
*/
- __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist));
+ __pyx_v_structural = (__pyx_v_dist * log(__pyx_v_delta));
/* "ml.pyx":18
- * structural = delta ** (dist)
+ * structural = dist * log(delta)
* # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = exp(-alpha * dt) * (1 - exp(-alpha)) # <<<<<<<<<<<<<<
- * result = log(structural * temporal)
- * return result
+ * temporal = log(alpha) - alpha * dt # <<<<<<<<<<<<<<
+ * # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
+ * result = structural + temporal
*/
- __pyx_v_temporal = (exp(((-__pyx_v_alpha) * __pyx_v_dt)) * (1.0 - exp((-__pyx_v_alpha))));
+ __pyx_v_temporal = (log(__pyx_v_alpha) - (__pyx_v_alpha * __pyx_v_dt));
- /* "ml.pyx":19
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = exp(-alpha * dt) * (1 - exp(-alpha))
- * result = log(structural * temporal) # <<<<<<<<<<<<<<
+ /* "ml.pyx":20
+ * temporal = log(alpha) - alpha * dt
+ * # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
+ * result = structural + temporal # <<<<<<<<<<<<<<
* return result
*
*/
- __pyx_v_result = log((__pyx_v_structural * __pyx_v_temporal));
+ __pyx_v_result = (__pyx_v_structural + __pyx_v_temporal);
- /* "ml.pyx":20
- * temporal = exp(-alpha * dt) * (1 - exp(-alpha))
- * result = log(structural * temporal)
+ /* "ml.pyx":21
+ * # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
+ * result = structural + temporal
* return result # <<<<<<<<<<<<<<
*
- *
+ * cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta,
*/
__pyx_r = __pyx_v_result;
goto __pyx_L0;
@@ -1525,75 +1520,8 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success(int __pyx_v_dist, int __py
}
/* "ml.pyx":23
- *
- *
- * cdef DTYPE_t weight_success_power(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<<
- * DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
- * """weight for successful infection, power-law time model"""
- */
-
-static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_success_power(int __pyx_v_dist, int __pyx_v_dt, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_w1, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_w2, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_w3) {
- __pyx_t_2ml_DTYPE_t __pyx_v_structural;
- __pyx_t_2ml_DTYPE_t __pyx_v_temporal;
- __pyx_t_2ml_DTYPE_t __pyx_v_result;
- __pyx_t_2ml_DTYPE_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("weight_success_power", 0);
-
- /* "ml.pyx":27
- * """weight for successful infection, power-law time model"""
- * cdef DTYPE_t structural, temporal, result
- * structural = delta ** (dist) # <<<<<<<<<<<<<<
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
- */
- __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist));
-
- /* "ml.pyx":29
- * structural = delta ** (dist)
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 # <<<<<<<<<<<<<<
- * result = log(structural * temporal)
- * return result
- */
- __pyx_v_temporal = ((1. / pow(((double)(1. + ((__pyx_v_dt - 1.) / __pyx_v_alpha))), 0.01)) - (1. / pow(((double)(1. + (__pyx_v_dt / __pyx_v_alpha))), 0.01)));
-
- /* "ml.pyx":30
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
- * result = log(structural * temporal) # <<<<<<<<<<<<<<
* return result
*
- */
- __pyx_v_result = log((__pyx_v_structural * __pyx_v_temporal));
-
- /* "ml.pyx":31
- * temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
- * result = log(structural * temporal)
- * return result # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "ml.pyx":23
- *
- *
- * cdef DTYPE_t weight_success_power(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<<
- * DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
- * """weight for successful infection, power-law time model"""
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "ml.pyx":34
- *
- *
* cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<<
* DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
* """weight for failed infection, exponential time model"""
@@ -1607,45 +1535,45 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int __pyx_v_dist, int __py
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("weight_failure", 0);
- /* "ml.pyx":38
+ /* "ml.pyx":27
* """weight for failed infection, exponential time model"""
* cdef DTYPE_t structural, temporal, result
- * structural = delta ** (dist) # <<<<<<<<<<<<<<
+ * structural = delta ** dist # <<<<<<<<<<<<<<
* # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
* temporal = 1. - exp(-alpha * dt)
*/
__pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist));
- /* "ml.pyx":40
- * structural = delta ** (dist)
+ /* "ml.pyx":29
+ * structural = delta ** dist
* # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
* temporal = 1. - exp(-alpha * dt) # <<<<<<<<<<<<<<
- * #result = log(1. - structural)
+ * # temporal = 1. - 1. / (1. + dt/alpha)**0.01
* result = log(1. - structural * temporal)
*/
__pyx_v_temporal = (1. - exp(((-__pyx_v_alpha) * __pyx_v_dt)));
- /* "ml.pyx":42
+ /* "ml.pyx":31
* temporal = 1. - exp(-alpha * dt)
- * #result = log(1. - structural)
+ * # temporal = 1. - 1. / (1. + dt/alpha)**0.01
* result = log(1. - structural * temporal) # <<<<<<<<<<<<<<
* return result
*
*/
__pyx_v_result = log((1. - (__pyx_v_structural * __pyx_v_temporal)));
- /* "ml.pyx":43
- * #result = log(1. - structural)
+ /* "ml.pyx":32
+ * # temporal = 1. - 1. / (1. + dt/alpha)**0.01
* result = log(1. - structural * temporal)
* return result # <<<<<<<<<<<<<<
*
- *
+ * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
*/
__pyx_r = __pyx_v_result;
goto __pyx_L0;
- /* "ml.pyx":34
- *
+ /* "ml.pyx":23
+ * return result
*
* cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<<
* DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
@@ -1658,74 +1586,7 @@ static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure(int __pyx_v_dist, int __py
return __pyx_r;
}
-/* "ml.pyx":46
- *
- *
- * cdef DTYPE_t weight_failure_power(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<<
- * DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
- * """weight for failed infection, power-law time model"""
- */
-
-static __pyx_t_2ml_DTYPE_t __pyx_f_2ml_weight_failure_power(int __pyx_v_dist, int __pyx_v_dt, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_w1, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_w2, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_w3) {
- __pyx_t_2ml_DTYPE_t __pyx_v_structural;
- __pyx_t_2ml_DTYPE_t __pyx_v_temporal;
- __pyx_t_2ml_DTYPE_t __pyx_v_result;
- __pyx_t_2ml_DTYPE_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("weight_failure_power", 0);
-
- /* "ml.pyx":50
- * """weight for failed infection, power-law time model"""
- * cdef DTYPE_t structural, temporal, result
- * structural = delta ** (dist) # <<<<<<<<<<<<<<
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = 1. - 1. / (1. + dt/alpha)**0.01
- */
- __pyx_v_structural = pow(__pyx_v_delta, ((__pyx_t_2ml_DTYPE_t)__pyx_v_dist));
-
- /* "ml.pyx":52
- * structural = delta ** (dist)
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = 1. - 1. / (1. + dt/alpha)**0.01 # <<<<<<<<<<<<<<
- * result = log(1. - structural * temporal)
- * return result
- */
- __pyx_v_temporal = (1. - (1. / pow(((double)(1. + (__pyx_v_dt / __pyx_v_alpha))), 0.01)));
-
- /* "ml.pyx":53
- * # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- * temporal = 1. - 1. / (1. + dt/alpha)**0.01
- * result = log(1. - structural * temporal) # <<<<<<<<<<<<<<
- * return result
- *
- */
- __pyx_v_result = log((1. - (__pyx_v_structural * __pyx_v_temporal)));
-
- /* "ml.pyx":54
- * temporal = 1. - 1. / (1. + dt/alpha)**0.01
- * result = log(1. - structural * temporal)
- * return result # <<<<<<<<<<<<<<
- *
- * def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
- */
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "ml.pyx":46
- *
- *
- * cdef DTYPE_t weight_failure_power(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, # <<<<<<<<<<<<<<
- * DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
- * """weight for failed infection, power-law time model"""
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "ml.pyx":56
+/* "ml.pyx":34
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
@@ -1740,7 +1601,7 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py
PyObject *__pyx_v_root_victims = 0;
PyObject *__pyx_v_victims = 0;
PyObject *__pyx_v_non_victims = 0;
- __pyx_t_2ml_DTYPE_t __pyx_v_age;
+ CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_age;
__pyx_t_2ml_DTYPE_t __pyx_v_alpha;
__pyx_t_2ml_DTYPE_t __pyx_v_delta;
int __pyx_lineno = 0;
@@ -1773,31 +1634,31 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_victims)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_non_victims)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 3:
if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_age)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 4:
if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_alpha)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 5:
if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_delta)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ml") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ml") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
goto __pyx_L5_argtuple_error;
@@ -1812,21 +1673,21 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py
__pyx_v_root_victims = ((PyObject*)values[0]);
__pyx_v_victims = ((PyObject*)values[1]);
__pyx_v_non_victims = ((PyObject*)values[2]);
- __pyx_v_age = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_age == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_alpha == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
- __pyx_v_delta = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_delta == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_age = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_age == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_alpha = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_alpha == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_delta = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_delta == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("ml", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("ml.ml", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root_victims), (&PyDict_Type), 1, "root_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_victims), (&PyDict_Type), 1, "victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_non_victims), (&PyDict_Type), 1, "non_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root_victims), (&PyDict_Type), 1, "root_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_victims), (&PyDict_Type), 1, "victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_non_victims), (&PyDict_Type), 1, "non_victims", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = __pyx_pf_2ml_ml(__pyx_self, __pyx_v_root_victims, __pyx_v_victims, __pyx_v_non_victims, __pyx_v_age, __pyx_v_alpha, __pyx_v_delta);
/* function exit code */
@@ -1839,7 +1700,7 @@ static PyObject *__pyx_pw_2ml_1ml(PyObject *__pyx_self, PyObject *__pyx_args, Py
}
static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
-/* "ml.pyx":80
+/* "ml.pyx":58
* for (dist, dt, w1, w2, w3) in parents]
* # find parent that maximizes log(p) - log(\tilde{p})
* probs[i] = max(s - failures[l] for l, s in enumerate(successes)) # <<<<<<<<<<<<<<
@@ -1865,7 +1726,7 @@ static PyObject *__pyx_pf_2ml_2ml_genexpr(PyObject *__pyx_self) {
__Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
{
- __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_2ml_2ml_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ml_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_2ml_2ml_2generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ml_locals_genexpr); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -1903,16 +1764,16 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = 0;
- if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_successes)) { __Pyx_RaiseClosureNameError("successes"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_successes)) { __Pyx_RaiseClosureNameError("successes"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
__pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_successes; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
for (;;) {
if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
#if CYTHON_COMPILING_IN_CPYTHON
- __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
- __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s, __pyx_t_4);
@@ -1920,14 +1781,14 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera
__pyx_t_4 = 0;
__pyx_cur_scope->__pyx_v_l = __pyx_t_1;
__pyx_t_1 = (__pyx_t_1 + 1);
- if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures)) { __Pyx_RaiseClosureNameError("failures"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+ if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures)) { __Pyx_RaiseClosureNameError("failures"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures, __pyx_cur_scope->__pyx_v_l, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_failures, __pyx_cur_scope->__pyx_v_l, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 0); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_s, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_s, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_r = __pyx_t_5;
@@ -1947,7 +1808,7 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera
__pyx_cur_scope->__pyx_t_1 = 0;
__Pyx_XGOTREF(__pyx_t_2);
__pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
- if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -1967,7 +1828,7 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera
return NULL;
}
-/* "ml.pyx":56
+/* "ml.pyx":34
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
@@ -1975,11 +1836,11 @@ static PyObject *__pyx_gb_2ml_2ml_2generator(__pyx_GeneratorObject *__pyx_genera
* cdef:
*/
-static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_root_victims, PyObject *__pyx_v_victims, PyObject *__pyx_v_non_victims, __pyx_t_2ml_DTYPE_t __pyx_v_age, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta) {
+static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_root_victims, PyObject *__pyx_v_victims, PyObject *__pyx_v_non_victims, CYTHON_UNUSED __pyx_t_2ml_DTYPE_t __pyx_v_age, __pyx_t_2ml_DTYPE_t __pyx_v_alpha, __pyx_t_2ml_DTYPE_t __pyx_v_delta) {
struct __pyx_obj_2ml___pyx_scope_struct__ml *__pyx_cur_scope;
int __pyx_v_n_roots;
int __pyx_v_n_victims;
- CYTHON_UNUSED int __pyx_v_n_nodes;
+ int __pyx_v_n_nodes;
int __pyx_v_roots;
int __pyx_v_i;
int __pyx_v_dist;
@@ -1990,12 +1851,13 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
PyArrayObject *__pyx_v_probs = 0;
PyArrayObject *__pyx_v_probs_fail = 0;
PyArrayObject *__pyx_v_probs_nv = 0;
- PyArrayObject *__pyx_v_cums = 0;
+ PyObject *__pyx_v_max_i = NULL;
+ PyObject *__pyx_v_max_beta_add = NULL;
+ double __pyx_v_thresh;
+ PyObject *__pyx_v_beta_add = NULL;
PyObject *__pyx_v_w1 = NULL;
PyObject *__pyx_v_w2 = NULL;
PyObject *__pyx_v_w3 = NULL;
- __Pyx_LocalBuf_ND __pyx_pybuffernd_cums;
- __Pyx_Buffer __pyx_pybuffer_cums;
__Pyx_LocalBuf_ND __pyx_pybuffernd_probs;
__Pyx_Buffer __pyx_pybuffer_probs;
__Pyx_LocalBuf_ND __pyx_pybuffernd_probs_fail;
@@ -2030,11 +1892,9 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_t_2ml_DTYPE_t __pyx_t_24;
int __pyx_t_25;
int __pyx_t_26;
- PyObject *__pyx_t_27 = NULL;
- PyObject *__pyx_t_28 = NULL;
- PyObject *__pyx_t_29 = NULL;
- PyArrayObject *__pyx_t_30 = NULL;
- int __pyx_t_31;
+ double __pyx_t_27;
+ long __pyx_t_28;
+ int __pyx_t_29;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
@@ -2057,82 +1917,73 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_pybuffer_probs_nv.refcount = 0;
__pyx_pybuffernd_probs_nv.data = NULL;
__pyx_pybuffernd_probs_nv.rcbuffer = &__pyx_pybuffer_probs_nv;
- __pyx_pybuffer_cums.pybuffer.buf = NULL;
- __pyx_pybuffer_cums.refcount = 0;
- __pyx_pybuffernd_cums.data = NULL;
- __pyx_pybuffernd_cums.rcbuffer = &__pyx_pybuffer_cums;
- /* "ml.pyx":62
+ /* "ml.pyx":40
* DTYPE_t beta, ll, beta2
* list parents, failures, successes
* n_roots, n_victims = len(root_victims), len(victims) # <<<<<<<<<<<<<<
- * n_nodes = n_roots + n_victims + len(non_victims)
+ * n_nodes = 148152
* cdef:
*/
if (unlikely(__pyx_v_root_victims == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_1 = PyDict_Size(__pyx_v_root_victims); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyDict_Size(__pyx_v_root_victims); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (unlikely(__pyx_v_victims == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_2 = PyDict_Size(__pyx_v_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyDict_Size(__pyx_v_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_n_roots = __pyx_t_1;
__pyx_v_n_victims = __pyx_t_2;
- /* "ml.pyx":63
+ /* "ml.pyx":41
* list parents, failures, successes
* n_roots, n_victims = len(root_victims), len(victims)
- * n_nodes = n_roots + n_victims + len(non_victims) # <<<<<<<<<<<<<<
+ * n_nodes = 148152 # <<<<<<<<<<<<<<
* cdef:
* np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE)
*/
- if (unlikely(__pyx_v_non_victims == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- __pyx_t_2 = PyDict_Size(__pyx_v_non_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_v_n_nodes = ((__pyx_v_n_roots + __pyx_v_n_victims) + __pyx_t_2);
+ __pyx_v_n_nodes = 148152;
- /* "ml.pyx":65
- * n_nodes = n_roots + n_victims + len(non_victims)
+ /* "ml.pyx":43
+ * n_nodes = 148152
* cdef:
* np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<<
* np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE)
* np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE)
*/
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
- __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_7 = ((PyArrayObject *)__pyx_t_6);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
__pyx_v_probs = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf = NULL;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} else {__pyx_pybuffernd_probs.diminfo[0].strides = __pyx_pybuffernd_probs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs.diminfo[0].shape = __pyx_pybuffernd_probs.rcbuffer->pybuffer.shape[0];
}
}
@@ -2140,43 +1991,43 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_v_probs = ((PyArrayObject *)__pyx_t_6);
__pyx_t_6 = 0;
- /* "ml.pyx":66
+ /* "ml.pyx":44
* cdef:
* np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE)
* np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) # <<<<<<<<<<<<<<
* np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE)
*
*/
- __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_n_victims); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
__Pyx_GIVEREF(__pyx_t_6);
__pyx_t_6 = 0;
- __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_8 = ((PyArrayObject *)__pyx_t_4);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs_fail.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
__pyx_v_probs_fail = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.buf = NULL;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} else {__pyx_pybuffernd_probs_fail.diminfo[0].strides = __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs_fail.diminfo[0].shape = __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.shape[0];
}
}
@@ -2184,48 +2035,48 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_v_probs_fail = ((PyArrayObject *)__pyx_t_4);
__pyx_t_4 = 0;
- /* "ml.pyx":67
+ /* "ml.pyx":45
* np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE)
* np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE)
* np.ndarray[DTYPE_t] probs_nv = np.zeros(len(non_victims), dtype=DTYPE) # <<<<<<<<<<<<<<
*
* # loop through victims
*/
- __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(__pyx_v_non_victims == Py_None)) {
PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_2 = PyDict_Size(__pyx_v_non_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyDict_Size(__pyx_v_non_victims); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
- __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_9 = ((PyArrayObject *)__pyx_t_3);
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
__pyx_v_probs_nv = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.buf = NULL;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
} else {__pyx_pybuffernd_probs_nv.diminfo[0].strides = __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs_nv.diminfo[0].shape = __pyx_pybuffernd_probs_nv.rcbuffer->pybuffer.shape[0];
}
}
@@ -2233,7 +2084,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_v_probs_nv = ((PyArrayObject *)__pyx_t_3);
__pyx_t_3 = 0;
- /* "ml.pyx":70
+ /* "ml.pyx":48
*
* # loop through victims
* for i, parents in enumerate(victims.itervalues()): # <<<<<<<<<<<<<<
@@ -2244,9 +2095,9 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_t_2 = 0;
if (unlikely(__pyx_v_victims == Py_None)) {
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "itervalues");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_1), (&__pyx_t_11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_3);
__pyx_t_3 = __pyx_t_4;
@@ -2254,25 +2105,25 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
while (1) {
__pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_1, &__pyx_t_2, NULL, &__pyx_t_4, NULL, __pyx_t_11);
if (unlikely(__pyx_t_12 == 0)) break;
- if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_4));
__pyx_t_4 = 0;
__pyx_v_i = __pyx_t_10;
__pyx_t_10 = (__pyx_t_10 + 1);
- /* "ml.pyx":74
+ /* "ml.pyx":52
* # fail to infect it, also computes the probability that its most
* # likely parent infects it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<<
* for (dist, dt, w1, w2, w3) in parents]
* probs_fail[i] = sum(failures)
*/
- __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- /* "ml.pyx":75
+ /* "ml.pyx":53
* # likely parent infects it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<<
@@ -2281,15 +2132,15 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
*/
if (unlikely(__pyx_v_parents == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_5 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_5); __pyx_t_13 = 0;
for (;;) {
if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_5)) break;
#if CYTHON_COMPILING_IN_CPYTHON
- __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
- __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
PyObject* sequence = __pyx_t_6;
@@ -2301,7 +2152,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
if (unlikely(size != 5)) {
if (size > 5) __Pyx_RaiseTooManyValuesError(5);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
@@ -2327,7 +2178,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
Py_ssize_t i;
PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18};
for (i=0; i < 5; i++) {
- PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(item);
*(temps[i]) = item;
}
@@ -2337,7 +2188,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
} else {
Py_ssize_t index = -1;
PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18};
- __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext;
@@ -2346,7 +2197,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_GOTREF(item);
*(temps[index]) = item;
}
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_20 = NULL;
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
goto __pyx_L8_unpacking_done;
@@ -2354,12 +2205,12 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__pyx_t_20 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L8_unpacking_done:;
}
- __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_21 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_21 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_21 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
__pyx_v_dist = __pyx_t_12;
__pyx_v_dt = __pyx_t_21;
@@ -2370,22 +2221,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_18);
__pyx_t_18 = 0;
- /* "ml.pyx":74
+ /* "ml.pyx":52
* # fail to infect it, also computes the probability that its most
* # likely parent infects it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<<
* for (dist, dt, w1, w2, w3) in parents]
* probs_fail[i] = sum(failures)
*/
- __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- /* "ml.pyx":75
+ /* "ml.pyx":53
* # likely parent infects it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<<
@@ -2399,38 +2250,38 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
- /* "ml.pyx":76
+ /* "ml.pyx":54
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents]
* probs_fail[i] = sum(failures) # <<<<<<<<<<<<<<
* successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents]
*/
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_failures);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_failures);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_failures);
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_21 = __pyx_v_i;
if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_pybuffernd_probs_fail.diminfo[0].shape;
*__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs_fail.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_probs_fail.diminfo[0].strides) = __pyx_t_24;
- /* "ml.pyx":77
+ /* "ml.pyx":55
* for (dist, dt, w1, w2, w3) in parents]
* probs_fail[i] = sum(failures)
* successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<<
* for (dist, dt, w1, w2, w3) in parents]
* # find parent that maximizes log(p) - log(\tilde{p})
*/
- __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- /* "ml.pyx":78
+ /* "ml.pyx":56
* probs_fail[i] = sum(failures)
* successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<<
@@ -2439,15 +2290,15 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
*/
if (unlikely(__pyx_v_parents == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_4 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0;
for (;;) {
if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_COMPILING_IN_CPYTHON
- __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
- __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
PyObject* sequence = __pyx_t_6;
@@ -2459,7 +2310,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
if (unlikely(size != 5)) {
if (size > 5) __Pyx_RaiseTooManyValuesError(5);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
@@ -2485,7 +2336,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
Py_ssize_t i;
PyObject** temps[5] = {&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15,&__pyx_t_14};
for (i=0; i < 5; i++) {
- PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(item);
*(temps[i]) = item;
}
@@ -2495,7 +2346,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
} else {
Py_ssize_t index = -1;
PyObject** temps[5] = {&__pyx_t_18,&__pyx_t_17,&__pyx_t_16,&__pyx_t_15,&__pyx_t_14};
- __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext;
@@ -2504,7 +2355,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_GOTREF(item);
*(temps[index]) = item;
}
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_20 = NULL;
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
goto __pyx_L12_unpacking_done;
@@ -2512,12 +2363,12 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__pyx_t_20 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L12_unpacking_done:;
}
- __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_18); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
- __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_t_17); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
__pyx_v_dist = __pyx_t_12;
__pyx_v_dt = __pyx_t_25;
@@ -2528,22 +2379,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_14);
__pyx_t_14 = 0;
- /* "ml.pyx":77
+ /* "ml.pyx":55
* for (dist, dt, w1, w2, w3) in parents]
* probs_fail[i] = sum(failures)
* successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<<
* for (dist, dt, w1, w2, w3) in parents]
* # find parent that maximizes log(p) - log(\tilde{p})
*/
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_success(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_24, __pyx_t_23, __pyx_t_22)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_success(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_24, __pyx_t_23, __pyx_t_22)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- /* "ml.pyx":78
+ /* "ml.pyx":56
* probs_fail[i] = sum(failures)
* successes = [weight_success(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<<
@@ -2557,24 +2408,24 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
- /* "ml.pyx":80
+ /* "ml.pyx":58
* for (dist, dt, w1, w2, w3) in parents]
* # find parent that maximizes log(p) - log(\tilde{p})
* probs[i] = max(s - failures[l] for l, s in enumerate(successes)) # <<<<<<<<<<<<<<
*
* # loop through non-victims
*/
- __pyx_t_5 = __pyx_pf_2ml_2ml_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __pyx_pf_2ml_2ml_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_max, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_25 = __pyx_v_i;
if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_pybuffernd_probs.diminfo[0].shape;
@@ -2582,7 +2433,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- /* "ml.pyx":83
+ /* "ml.pyx":61
*
* # loop through non-victims
* for i, parents in enumerate(non_victims.itervalues()): # <<<<<<<<<<<<<<
@@ -2593,9 +2444,9 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_t_1 = 0;
if (unlikely(__pyx_v_non_victims == Py_None)) {
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "itervalues");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_non_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_2), (&__pyx_t_11)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_non_victims, 1, __pyx_n_s_itervalues, (&__pyx_t_2), (&__pyx_t_11)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_3);
__pyx_t_3 = __pyx_t_5;
@@ -2603,25 +2454,25 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
while (1) {
__pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_2, &__pyx_t_1, NULL, &__pyx_t_5, NULL, __pyx_t_11);
if (unlikely(__pyx_t_12 == 0)) break;
- if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_XDECREF_SET(__pyx_v_parents, ((PyObject*)__pyx_t_5));
__pyx_t_5 = 0;
__pyx_v_i = __pyx_t_10;
__pyx_t_10 = (__pyx_t_10 + 1);
- /* "ml.pyx":86
+ /* "ml.pyx":64
* # for each non victim node, compute the probability that all its
* # parents fail to infect it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<<
* for (dist, dt, w1, w2, w3) in parents]
* probs_nv[i] = sum(failures)
*/
- __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- /* "ml.pyx":87
+ /* "ml.pyx":65
* # parents fail to infect it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<<
@@ -2630,15 +2481,15 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
*/
if (unlikely(__pyx_v_parents == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_4 = __pyx_v_parents; __Pyx_INCREF(__pyx_t_4); __pyx_t_13 = 0;
for (;;) {
if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break;
#if CYTHON_COMPILING_IN_CPYTHON
- __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_6); __pyx_t_13++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
- __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
PyObject* sequence = __pyx_t_6;
@@ -2650,7 +2501,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
if (unlikely(size != 5)) {
if (size > 5) __Pyx_RaiseTooManyValuesError(5);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
@@ -2676,7 +2527,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
Py_ssize_t i;
PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18};
for (i=0; i < 5; i++) {
- PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(item);
*(temps[i]) = item;
}
@@ -2686,7 +2537,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
} else {
Py_ssize_t index = -1;
PyObject** temps[5] = {&__pyx_t_14,&__pyx_t_15,&__pyx_t_16,&__pyx_t_17,&__pyx_t_18};
- __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_19 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_19);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_20 = Py_TYPE(__pyx_t_19)->tp_iternext;
@@ -2695,7 +2546,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_GOTREF(item);
*(temps[index]) = item;
}
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_IternextUnpackEndCheck(__pyx_t_20(__pyx_t_19), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_20 = NULL;
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
goto __pyx_L18_unpacking_done;
@@ -2703,12 +2554,12 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
__pyx_t_20 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L18_unpacking_done:;
}
- __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_14); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
- __pyx_t_26 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_26 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_26 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_26 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
__pyx_v_dist = __pyx_t_12;
__pyx_v_dt = __pyx_t_26;
@@ -2719,22 +2570,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_XDECREF_SET(__pyx_v_w3, __pyx_t_18);
__pyx_t_18 = 0;
- /* "ml.pyx":86
+ /* "ml.pyx":64
* # for each non victim node, compute the probability that all its
* # parents fail to infect it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3) # <<<<<<<<<<<<<<
* for (dist, dt, w1, w2, w3) in parents]
* probs_nv[i] = sum(failures)
*/
- __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_v_w1); if (unlikely((__pyx_t_22 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_v_w2); if (unlikely((__pyx_t_23 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_v_w3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyFloat_FromDouble(__pyx_f_2ml_weight_failure(__pyx_v_dist, __pyx_v_dt, __pyx_v_alpha, __pyx_v_delta, __pyx_t_22, __pyx_t_23, __pyx_t_24)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- /* "ml.pyx":87
+ /* "ml.pyx":65
* # parents fail to infect it
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents] # <<<<<<<<<<<<<<
@@ -2748,22 +2599,22 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
- /* "ml.pyx":88
+ /* "ml.pyx":66
* failures = [weight_failure(dist, dt, alpha, delta, w1, w2, w3)
* for (dist, dt, w1, w2, w3) in parents]
* probs_nv[i] = sum(failures) # <<<<<<<<<<<<<<
*
* # calculate log likelihood
*/
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_failures);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_failures);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_failures);
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_26 = __pyx_v_i;
if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_pybuffernd_probs_nv.diminfo[0].shape;
@@ -2771,107 +2622,14 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- /* "ml.pyx":91
- *
- * # calculate log likelihood
- * probs.sort(); probs = probs[::-1] # sort probs in descending order # <<<<<<<<<<<<<<
- * cdef:
- * np.ndarray[DTYPE_t] cums = probs.cumsum()
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs), __pyx_n_s_sort); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_slice_); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
- __Pyx_GOTREF(__pyx_t_3);
- if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_7 = ((PyArrayObject *)__pyx_t_3);
- {
- __Pyx_BufFmt_StackElem __pyx_stack[1];
- __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer);
- __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
- if (unlikely(__pyx_t_10 < 0)) {
- PyErr_Fetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
- if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_probs.rcbuffer->pybuffer, (PyObject*)__pyx_v_probs, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
- Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_29);
- __Pyx_RaiseBufferFallbackError();
- } else {
- PyErr_Restore(__pyx_t_27, __pyx_t_28, __pyx_t_29);
- }
- }
- __pyx_pybuffernd_probs.diminfo[0].strides = __pyx_pybuffernd_probs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_probs.diminfo[0].shape = __pyx_pybuffernd_probs.rcbuffer->pybuffer.shape[0];
- if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- __pyx_t_7 = 0;
- __Pyx_DECREF_SET(__pyx_v_probs, ((PyArrayObject *)__pyx_t_3));
- __pyx_t_3 = 0;
-
- /* "ml.pyx":93
- * probs.sort(); probs = probs[::-1] # sort probs in descending order
- * cdef:
- * np.ndarray[DTYPE_t] cums = probs.cumsum() # <<<<<<<<<<<<<<
- * ll = probs_fail.sum()
- * ll += probs_nv.sum()
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs), __pyx_n_s_cumsum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = NULL;
- if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- } else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- }
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_30 = ((PyArrayObject *)__pyx_t_3);
- {
- __Pyx_BufFmt_StackElem __pyx_stack[1];
- if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cums.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_2ml_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
- __pyx_v_cums = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cums.rcbuffer->pybuffer.buf = NULL;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- } else {__pyx_pybuffernd_cums.diminfo[0].strides = __pyx_pybuffernd_cums.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cums.diminfo[0].shape = __pyx_pybuffernd_cums.rcbuffer->pybuffer.shape[0];
- }
- }
- __pyx_t_30 = 0;
- __pyx_v_cums = ((PyArrayObject *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "ml.pyx":94
- * cdef:
- * np.ndarray[DTYPE_t] cums = probs.cumsum()
- * ll = probs_fail.sum() # <<<<<<<<<<<<<<
- * ll += probs_nv.sum()
+ /* "ml.pyx":72
+ * # cdef:
+ * # np.ndarray[DTYPE_t] cums = probs.cumsum()
+ * ll = probs_fail.sum() # add probability that all edges to victims fail # <<<<<<<<<<<<<<
+ * ll += probs_nv.sum() # add probability that all edges to non_victims fail
*
*/
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_fail), __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = NULL;
if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
@@ -2884,27 +2642,27 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
}
}
if (__pyx_t_5) {
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
} else {
- __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_ll = __pyx_t_24;
- /* "ml.pyx":95
- * np.ndarray[DTYPE_t] cums = probs.cumsum()
- * ll = probs_fail.sum()
- * ll += probs_nv.sum() # <<<<<<<<<<<<<<
+ /* "ml.pyx":73
+ * # np.ndarray[DTYPE_t] cums = probs.cumsum()
+ * ll = probs_fail.sum() # add probability that all edges to victims fail
+ * ll += probs_nv.sum() # add probability that all edges to non_victims fail # <<<<<<<<<<<<<<
*
- * for i in xrange(n_victims - 1, 0, -1):
+ * max_i = -1
*/
- __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_nv), __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_probs_nv), __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = NULL;
if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
@@ -2917,261 +2675,233 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
}
}
if (__pyx_t_6) {
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
} else {
- __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_ll = __pyx_t_24;
- /* "ml.pyx":97
- * ll += probs_nv.sum()
+ /* "ml.pyx":75
+ * ll += probs_nv.sum() # add probability that all edges to non_victims fail
*
- * for i in xrange(n_victims - 1, 0, -1): # <<<<<<<<<<<<<<
- * # iterate over all victim nodes to find the optimal threshold
- * roots = n_roots + n_victims - 1 - i
+ * max_i = -1 # <<<<<<<<<<<<<<
+ * max_beta_add = float('-inf')
+ * # iterate over all victim nodes to find the optimal threshold
*/
- for (__pyx_t_10 = (__pyx_v_n_victims - 1); __pyx_t_10 > 0; __pyx_t_10-=1) {
- __pyx_v_i = __pyx_t_10;
+ __Pyx_INCREF(__pyx_int_neg_1);
+ __pyx_v_max_i = __pyx_int_neg_1;
- /* "ml.pyx":99
- * for i in xrange(n_victims - 1, 0, -1):
- * # iterate over all victim nodes to find the optimal threshold
- * roots = n_roots + n_victims - 1 - i # <<<<<<<<<<<<<<
- * beta = 1. / (1. + exp(-probs[i]))#exp(probs[i])#
- * if beta > float(roots) / age:
+ /* "ml.pyx":76
+ *
+ * max_i = -1
+ * max_beta_add = float('-inf') # <<<<<<<<<<<<<<
+ * # iterate over all victim nodes to find the optimal threshold
+ * for i in xrange(0, n_victims+1, 1):
*/
- __pyx_v_roots = (((__pyx_v_n_roots + __pyx_v_n_victims) - 1) - __pyx_v_i);
+ __pyx_t_27 = __Pyx_PyObject_AsDouble(__pyx_kp_s_inf); if (unlikely(__pyx_t_27 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyFloat_FromDouble(__pyx_t_27); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_v_max_beta_add = __pyx_t_5;
+ __pyx_t_5 = 0;
- /* "ml.pyx":100
- * # iterate over all victim nodes to find the optimal threshold
- * roots = n_roots + n_victims - 1 - i
- * beta = 1. / (1. + exp(-probs[i]))#exp(probs[i])# # <<<<<<<<<<<<<<
- * if beta > float(roots) / age:
- * break
+ /* "ml.pyx":78
+ * max_beta_add = float('-inf')
+ * # iterate over all victim nodes to find the optimal threshold
+ * for i in xrange(0, n_victims+1, 1): # <<<<<<<<<<<<<<
+ * roots = n_roots + n_victims - i
+ * beta = float(roots)/float(n_nodes)
*/
- __pyx_t_11 = __pyx_v_i;
- if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_pybuffernd_probs.diminfo[0].shape;
- __pyx_v_beta = (1. / (1. + exp((-(*__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_probs.diminfo[0].strides))))));
+ __pyx_t_28 = (__pyx_v_n_victims + 1);
+ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_28; __pyx_t_10+=1) {
+ __pyx_v_i = __pyx_t_10;
- /* "ml.pyx":101
- * roots = n_roots + n_victims - 1 - i
- * beta = 1. / (1. + exp(-probs[i]))#exp(probs[i])#
- * if beta > float(roots) / age: # <<<<<<<<<<<<<<
- * break
- * else:
+ /* "ml.pyx":79
+ * # iterate over all victim nodes to find the optimal threshold
+ * for i in xrange(0, n_victims+1, 1):
+ * roots = n_roots + n_victims - i # <<<<<<<<<<<<<<
+ * beta = float(roots)/float(n_nodes)
+ * thresh = log(beta/(1.-beta))
*/
- __pyx_t_31 = ((__pyx_v_beta > (((double)__pyx_v_roots) / __pyx_v_age)) != 0);
- if (__pyx_t_31) {
+ __pyx_v_roots = ((__pyx_v_n_roots + __pyx_v_n_victims) - __pyx_v_i);
- /* "ml.pyx":102
- * beta = 1. / (1. + exp(-probs[i]))#exp(probs[i])#
- * if beta > float(roots) / age:
- * break # <<<<<<<<<<<<<<
- * else:
- * print "alpha: {0}, delta: {1}. Everyone is a root".format(alpha, delta)
+ /* "ml.pyx":80
+ * for i in xrange(0, n_victims+1, 1):
+ * roots = n_roots + n_victims - i
+ * beta = float(roots)/float(n_nodes) # <<<<<<<<<<<<<<
+ * thresh = log(beta/(1.-beta))
+ *
*/
- goto __pyx_L20_break;
- }
- }
- /*else*/ {
+ __pyx_v_beta = (((double)__pyx_v_roots) / ((double)__pyx_v_n_nodes));
- /* "ml.pyx":104
- * break
- * else:
- * print "alpha: {0}, delta: {1}. Everyone is a root".format(alpha, delta) # <<<<<<<<<<<<<<
- * roots = n_victims + n_roots
- * i = -1
+ /* "ml.pyx":81
+ * roots = n_roots + n_victims - i
+ * beta = float(roots)/float(n_nodes)
+ * thresh = log(beta/(1.-beta)) # <<<<<<<<<<<<<<
+ *
+ * # add probability for realized edges and subtract probability these edges fail
+ */
+ __pyx_v_thresh = log((__pyx_v_beta / (1. - __pyx_v_beta)));
+
+ /* "ml.pyx":84
+ *
+ * # add probability for realized edges and subtract probability these edges fail
+ * beta_add = (probs[probs>thresh]).sum() # <<<<<<<<<<<<<<
+ * # add probability for the seeds and non-seeds
+ * beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta)
*/
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_alpha_0_delta_1_Everyone_is_a_ro, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyFloat_FromDouble(__pyx_v_alpha); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_t_3); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+ __Pyx_GOTREF(__pyx_t_4);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = PyFloat_FromDouble(__pyx_v_delta); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_18 = NULL;
- __pyx_t_2 = 0;
- if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_18)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_18);
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ __pyx_t_4 = NULL;
+ if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+ __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
+ if (likely(__pyx_t_4)) {
+ PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+ __Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_2 = 1;
+ __Pyx_DECREF_SET(__pyx_t_3, function);
}
}
- __pyx_t_17 = PyTuple_New(2+__pyx_t_2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_17);
- if (__pyx_t_18) {
- PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); __pyx_t_18 = NULL;
+ if (__pyx_t_4) {
+ __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+ } else {
+ __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
- PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_2, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_2, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_6);
- __pyx_t_3 = 0;
- __pyx_t_6 = 0;
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_17, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PrintOne(0, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "ml.pyx":105
- * else:
- * print "alpha: {0}, delta: {1}. Everyone is a root".format(alpha, delta)
- * roots = n_victims + n_roots # <<<<<<<<<<<<<<
- * i = -1
- * beta = float(roots) / age
- */
- __pyx_v_roots = (__pyx_v_n_victims + __pyx_v_n_roots);
-
- /* "ml.pyx":106
- * print "alpha: {0}, delta: {1}. Everyone is a root".format(alpha, delta)
- * roots = n_victims + n_roots
- * i = -1 # <<<<<<<<<<<<<<
- * beta = float(roots) / age
- * for i in xrange(n_victims - 1, 0, -1):
- */
- __pyx_v_i = -1;
- }
- __pyx_L20_break:;
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_XDECREF_SET(__pyx_v_beta_add, __pyx_t_5);
+ __pyx_t_5 = 0;
- /* "ml.pyx":107
- * roots = n_victims + n_roots
- * i = -1
- * beta = float(roots) / age # <<<<<<<<<<<<<<
- * for i in xrange(n_victims - 1, 0, -1):
- * if probs[i] >= log(beta/(1.- beta)):
+ /* "ml.pyx":86
+ * beta_add = (probs[probs>thresh]).sum()
+ * # add probability for the seeds and non-seeds
+ * beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta) # <<<<<<<<<<<<<<
+ *
+ * if beta_add > max_beta_add:
*/
- __pyx_v_beta = (((double)__pyx_v_roots) / __pyx_v_age);
+ __pyx_t_5 = PyFloat_FromDouble(((__pyx_v_roots * log(__pyx_v_beta)) + ((__pyx_v_n_nodes - __pyx_v_roots) * log((1.0 - __pyx_v_beta))))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_beta_add, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_DECREF_SET(__pyx_v_beta_add, __pyx_t_3);
+ __pyx_t_3 = 0;
- /* "ml.pyx":108
- * i = -1
- * beta = float(roots) / age
- * for i in xrange(n_victims - 1, 0, -1): # <<<<<<<<<<<<<<
- * if probs[i] >= log(beta/(1.- beta)):
- * break
+ /* "ml.pyx":88
+ * beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta)
+ *
+ * if beta_add > max_beta_add: # <<<<<<<<<<<<<<
+ * max_i = i
+ * max_beta_add = beta_add
*/
- for (__pyx_t_10 = (__pyx_v_n_victims - 1); __pyx_t_10 > 0; __pyx_t_10-=1) {
- __pyx_v_i = __pyx_t_10;
+ __pyx_t_3 = PyObject_RichCompare(__pyx_v_beta_add, __pyx_v_max_beta_add, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_29 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ if (__pyx_t_29) {
- /* "ml.pyx":109
- * beta = float(roots) / age
- * for i in xrange(n_victims - 1, 0, -1):
- * if probs[i] >= log(beta/(1.- beta)): # <<<<<<<<<<<<<<
- * break
- * ll += age * log(1 - beta)
+ /* "ml.pyx":89
+ *
+ * if beta_add > max_beta_add:
+ * max_i = i # <<<<<<<<<<<<<<
+ * max_beta_add = beta_add
+ *
*/
- __pyx_t_12 = __pyx_v_i;
- if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_pybuffernd_probs.diminfo[0].shape;
- __pyx_t_31 = (((*__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_probs.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_probs.diminfo[0].strides)) >= log((__pyx_v_beta / (1. - __pyx_v_beta)))) != 0);
- if (__pyx_t_31) {
+ __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF_SET(__pyx_v_max_i, __pyx_t_3);
+ __pyx_t_3 = 0;
- /* "ml.pyx":110
- * for i in xrange(n_victims - 1, 0, -1):
- * if probs[i] >= log(beta/(1.- beta)):
- * break # <<<<<<<<<<<<<<
- * ll += age * log(1 - beta)
- * if i >= 0:
+ /* "ml.pyx":90
+ * if beta_add > max_beta_add:
+ * max_i = i
+ * max_beta_add = beta_add # <<<<<<<<<<<<<<
+ *
+ * ll += max_beta_add
*/
- goto __pyx_L23_break;
+ __Pyx_INCREF(__pyx_v_beta_add);
+ __Pyx_DECREF_SET(__pyx_v_max_beta_add, __pyx_v_beta_add);
+ goto __pyx_L21;
}
+ __pyx_L21:;
}
- __pyx_L23_break:;
-
- /* "ml.pyx":111
- * if probs[i] >= log(beta/(1.- beta)):
- * break
- * ll += age * log(1 - beta) # <<<<<<<<<<<<<<
- * if i >= 0:
- * ll += cums[i]
- */
- __pyx_v_ll = (__pyx_v_ll + (__pyx_v_age * log((1.0 - __pyx_v_beta))));
-
- /* "ml.pyx":112
- * break
- * ll += age * log(1 - beta)
- * if i >= 0: # <<<<<<<<<<<<<<
- * ll += cums[i]
- * if roots > 0:
- */
- __pyx_t_31 = ((__pyx_v_i >= 0) != 0);
- if (__pyx_t_31) {
-
- /* "ml.pyx":113
- * ll += age * log(1 - beta)
- * if i >= 0:
- * ll += cums[i] # <<<<<<<<<<<<<<
- * if roots > 0:
- * ll += roots * log(beta) - roots * log(1 - beta)
- */
- __pyx_t_10 = __pyx_v_i;
- if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_pybuffernd_cums.diminfo[0].shape;
- __pyx_v_ll = (__pyx_v_ll + (*__Pyx_BufPtrStrided1d(__pyx_t_2ml_DTYPE_t *, __pyx_pybuffernd_cums.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_cums.diminfo[0].strides)));
- goto __pyx_L25;
- }
- __pyx_L25:;
- /* "ml.pyx":114
- * if i >= 0:
- * ll += cums[i]
- * if roots > 0: # <<<<<<<<<<<<<<
- * ll += roots * log(beta) - roots * log(1 - beta)
- * return (beta, roots, ll)
+ /* "ml.pyx":92
+ * max_beta_add = beta_add
+ *
+ * ll += max_beta_add # <<<<<<<<<<<<<<
+ * roots = n_roots + n_victims - max_i
+ * # print n_nodes, n_roots, n_victims, max_i, roots
*/
- __pyx_t_31 = ((__pyx_v_roots > 0) != 0);
- if (__pyx_t_31) {
+ __pyx_t_3 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_max_beta_add); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_24 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_v_ll = __pyx_t_24;
- /* "ml.pyx":115
- * ll += cums[i]
- * if roots > 0:
- * ll += roots * log(beta) - roots * log(1 - beta) # <<<<<<<<<<<<<<
+ /* "ml.pyx":93
+ *
+ * ll += max_beta_add
+ * roots = n_roots + n_victims - max_i # <<<<<<<<<<<<<<
+ * # print n_nodes, n_roots, n_victims, max_i, roots
* return (beta, roots, ll)
*/
- __pyx_v_ll = (__pyx_v_ll + ((__pyx_v_roots * log(__pyx_v_beta)) - (__pyx_v_roots * log((1.0 - __pyx_v_beta)))));
- goto __pyx_L26;
- }
- __pyx_L26:;
+ __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_n_roots + __pyx_v_n_victims)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_v_max_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_v_roots = __pyx_t_10;
- /* "ml.pyx":116
- * if roots > 0:
- * ll += roots * log(beta) - roots * log(1 - beta)
+ /* "ml.pyx":95
+ * roots = n_roots + n_victims - max_i
+ * # print n_nodes, n_roots, n_victims, max_i, roots
* return (beta, roots, ll) # <<<<<<<<<<<<<<
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_5 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyFloat_FromDouble(__pyx_v_beta); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
- __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_17 = PyFloat_FromDouble(__pyx_v_ll); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_t_17);
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_17);
- __Pyx_GIVEREF(__pyx_t_17);
+ __pyx_t_3 = 0;
__pyx_t_5 = 0;
__pyx_t_4 = 0;
- __pyx_t_17 = 0;
__pyx_r = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L0;
- /* "ml.pyx":56
+ /* "ml.pyx":34
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
@@ -3193,7 +2923,6 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_XDECREF(__pyx_t_19);
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
- __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cums.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_fail.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer);
@@ -3202,7 +2931,6 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__pyx_r = NULL;
goto __pyx_L2;
__pyx_L0:;
- __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cums.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_fail.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_probs_nv.rcbuffer->pybuffer);
@@ -3211,7 +2939,9 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_
__Pyx_XDECREF((PyObject *)__pyx_v_probs);
__Pyx_XDECREF((PyObject *)__pyx_v_probs_fail);
__Pyx_XDECREF((PyObject *)__pyx_v_probs_nv);
- __Pyx_XDECREF((PyObject *)__pyx_v_cums);
+ __Pyx_XDECREF(__pyx_v_max_i);
+ __Pyx_XDECREF(__pyx_v_max_beta_add);
+ __Pyx_XDECREF(__pyx_v_beta_add);
__Pyx_XDECREF(__pyx_v_w1);
__Pyx_XDECREF(__pyx_v_w2);
__Pyx_XDECREF(__pyx_v_w3);
@@ -3377,7 +3107,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
*/
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -3417,7 +3147,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
*
* info.buf = PyArray_DATA(self)
*/
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -3694,7 +3424,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B"
*/
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -4506,7 +4236,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
*
* if ((child.byteorder == c'>' and little_endian) or
*/
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -4558,7 +4288,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
* # One could encode it in the format string and have Cython
* # complain instead, BUT: < and > in format strings also imply
*/
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -4659,7 +4389,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx
*
* # Until ticket #99 is fixed, use integers to avoid warnings
*/
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_Raise(__pyx_t_4, 0, 0, 0);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
@@ -5482,31 +5212,29 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
{&__pyx_n_s_age, __pyx_k_age, sizeof(__pyx_k_age), 0, 0, 1, 1},
{&__pyx_n_s_alpha, __pyx_k_alpha, sizeof(__pyx_k_alpha), 0, 0, 1, 1},
- {&__pyx_kp_s_alpha_0_delta_1_Everyone_is_a_ro, __pyx_k_alpha_0_delta_1_Everyone_is_a_ro, sizeof(__pyx_k_alpha_0_delta_1_Everyone_is_a_ro), 0, 0, 1, 0},
{&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
{&__pyx_n_s_beta, __pyx_k_beta, sizeof(__pyx_k_beta), 0, 0, 1, 1},
{&__pyx_n_s_beta2, __pyx_k_beta2, sizeof(__pyx_k_beta2), 0, 0, 1, 1},
+ {&__pyx_n_s_beta_add, __pyx_k_beta_add, sizeof(__pyx_k_beta_add), 0, 0, 1, 1},
{&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_cums, __pyx_k_cums, sizeof(__pyx_k_cums), 0, 0, 1, 1},
- {&__pyx_n_s_cumsum, __pyx_k_cumsum, sizeof(__pyx_k_cumsum), 0, 0, 1, 1},
{&__pyx_n_s_delta, __pyx_k_delta, sizeof(__pyx_k_delta), 0, 0, 1, 1},
{&__pyx_n_s_dist, __pyx_k_dist, sizeof(__pyx_k_dist), 0, 0, 1, 1},
{&__pyx_n_s_dt, __pyx_k_dt, sizeof(__pyx_k_dt), 0, 0, 1, 1},
{&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
- {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
{&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
{&__pyx_n_s_failures, __pyx_k_failures, sizeof(__pyx_k_failures), 0, 0, 1, 1},
- {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
{&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
- {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
{&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
{&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
{&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
+ {&__pyx_kp_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 0},
{&__pyx_n_s_itervalues, __pyx_k_itervalues, sizeof(__pyx_k_itervalues), 0, 0, 1, 1},
{&__pyx_n_s_l, __pyx_k_l, sizeof(__pyx_k_l), 0, 0, 1, 1},
{&__pyx_n_s_ll, __pyx_k_ll, sizeof(__pyx_k_ll), 0, 0, 1, 1},
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
{&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
+ {&__pyx_n_s_max_beta_add, __pyx_k_max_beta_add, sizeof(__pyx_k_max_beta_add), 0, 0, 1, 1},
+ {&__pyx_n_s_max_i, __pyx_k_max_i, sizeof(__pyx_k_max_i), 0, 0, 1, 1},
{&__pyx_n_s_ml, __pyx_k_ml, sizeof(__pyx_k_ml), 0, 0, 1, 1},
{&__pyx_n_s_ml_locals_genexpr, __pyx_k_ml_locals_genexpr, sizeof(__pyx_k_ml_locals_genexpr), 0, 0, 1, 1},
{&__pyx_n_s_n_nodes, __pyx_k_n_nodes, sizeof(__pyx_k_n_nodes), 0, 0, 1, 1},
@@ -5518,7 +5246,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
{&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
{&__pyx_n_s_parents, __pyx_k_parents, sizeof(__pyx_k_parents), 0, 0, 1, 1},
- {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
{&__pyx_n_s_probs, __pyx_k_probs, sizeof(__pyx_k_probs), 0, 0, 1, 1},
{&__pyx_n_s_probs_fail, __pyx_k_probs_fail, sizeof(__pyx_k_probs_fail), 0, 0, 1, 1},
{&__pyx_n_s_probs_nv, __pyx_k_probs_nv, sizeof(__pyx_k_probs_nv), 0, 0, 1, 1},
@@ -5526,11 +5253,11 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_root_victims, __pyx_k_root_victims, sizeof(__pyx_k_root_victims), 0, 0, 1, 1},
{&__pyx_n_s_roots, __pyx_k_roots, sizeof(__pyx_k_roots), 0, 0, 1, 1},
{&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
- {&__pyx_n_s_sort, __pyx_k_sort, sizeof(__pyx_k_sort), 0, 0, 1, 1},
{&__pyx_n_s_successes, __pyx_k_successes, sizeof(__pyx_k_successes), 0, 0, 1, 1},
{&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
{&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
{&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
+ {&__pyx_n_s_thresh, __pyx_k_thresh, sizeof(__pyx_k_thresh), 0, 0, 1, 1},
{&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
{&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
{&__pyx_n_s_victims, __pyx_k_victims, sizeof(__pyx_k_victims), 0, 0, 1, 1},
@@ -5542,13 +5269,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#if PY_MAJOR_VERSION >= 3
- __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#else
- __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -5562,17 +5289,6 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
- /* "ml.pyx":91
- *
- * # calculate log likelihood
- * probs.sort(); probs = probs[::-1] # sort probs in descending order # <<<<<<<<<<<<<<
- * cdef:
- * np.ndarray[DTYPE_t] cums = probs.cumsum()
- */
- __pyx_slice_ = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_slice_);
- __Pyx_GIVEREF(__pyx_slice_);
-
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218
* if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
* and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
@@ -5580,9 +5296,9 @@ static int __Pyx_InitCachedConstants(void) {
*
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
*/
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
+ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple_);
+ __Pyx_GIVEREF(__pyx_tuple_);
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222
* if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
@@ -5591,9 +5307,9 @@ static int __Pyx_InitCachedConstants(void) {
*
* info.buf = PyArray_DATA(self)
*/
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
+ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple__2);
+ __Pyx_GIVEREF(__pyx_tuple__2);
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260
* if ((descr.byteorder == c'>' and little_endian) or
@@ -5602,9 +5318,9 @@ static int __Pyx_InitCachedConstants(void) {
* if t == NPY_BYTE: f = "b"
* elif t == NPY_UBYTE: f = "B"
*/
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
+ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple__3);
+ __Pyx_GIVEREF(__pyx_tuple__3);
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802
*
@@ -5613,9 +5329,9 @@ static int __Pyx_InitCachedConstants(void) {
*
* if ((child.byteorder == c'>' and little_endian) or
*/
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
+ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple__4);
+ __Pyx_GIVEREF(__pyx_tuple__4);
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":806
* if ((child.byteorder == c'>' and little_endian) or
@@ -5624,9 +5340,9 @@ static int __Pyx_InitCachedConstants(void) {
* # One could encode it in the format string and have Cython
* # complain instead, BUT: < and > in format strings also imply
*/
- __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
+ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple__5);
+ __Pyx_GIVEREF(__pyx_tuple__5);
/* "../../../../Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826
* t = child.type_num
@@ -5635,21 +5351,21 @@ static int __Pyx_InitCachedConstants(void) {
*
* # Until ticket #99 is fixed, use integers to avoid warnings
*/
- __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
+ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple__6);
+ __Pyx_GIVEREF(__pyx_tuple__6);
- /* "ml.pyx":56
+ /* "ml.pyx":34
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
* DTYPE_t alpha, DTYPE_t delta):
* cdef:
*/
- __pyx_tuple__8 = PyTuple_Pack(30, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_n_nodes, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta2, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_probs_nv, __pyx_n_s_cums, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(__pyx_tuple__8);
- __Pyx_GIVEREF(__pyx_tuple__8);
- __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(6, 0, 30, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml, 56, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_tuple__7 = PyTuple_Pack(33, __pyx_n_s_root_victims, __pyx_n_s_victims, __pyx_n_s_non_victims, __pyx_n_s_age, __pyx_n_s_alpha, __pyx_n_s_delta, __pyx_n_s_n_roots, __pyx_n_s_n_victims, __pyx_n_s_n_nodes, __pyx_n_s_roots, __pyx_n_s_i, __pyx_n_s_dist, __pyx_n_s_dt, __pyx_n_s_t, __pyx_n_s_l, __pyx_n_s_beta, __pyx_n_s_ll, __pyx_n_s_beta2, __pyx_n_s_parents, __pyx_n_s_failures, __pyx_n_s_successes, __pyx_n_s_probs, __pyx_n_s_probs_fail, __pyx_n_s_probs_nv, __pyx_n_s_max_i, __pyx_n_s_max_beta_add, __pyx_n_s_thresh, __pyx_n_s_beta_add, __pyx_n_s_w1, __pyx_n_s_w2, __pyx_n_s_w3, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_tuple__7);
+ __Pyx_GIVEREF(__pyx_tuple__7);
+ __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(6, 0, 33, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ben_Documents_Cascade_Pro, __pyx_n_s_ml, 34, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -5746,10 +5462,10 @@ PyMODINIT_FUNC PyInit_ml(void)
/*--- Variable export code ---*/
/*--- Function export code ---*/
/*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct__ml) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct__ml) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_type_2ml___pyx_scope_struct__ml.tp_print = 0;
__pyx_ptype_2ml___pyx_scope_struct__ml = &__pyx_type_2ml___pyx_scope_struct__ml;
- if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_2ml___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_type_2ml___pyx_scope_struct_1_genexpr.tp_print = 0;
__pyx_ptype_2ml___pyx_scope_struct_1_genexpr = &__pyx_type_2ml___pyx_scope_struct_1_genexpr;
/*--- Type import code ---*/
@@ -5795,16 +5511,16 @@ PyMODINIT_FUNC PyInit_ml(void)
if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- /* "ml.pyx":56
+ /* "ml.pyx":34
* return result
*
* def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # <<<<<<<<<<<<<<
* DTYPE_t alpha, DTYPE_t delta):
* cdef:
*/
- __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_2ml_1ml, NULL, __pyx_n_s_ml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_2ml_1ml, NULL, __pyx_n_s_ml); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_ml, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s_ml, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "ml.pyx":1
@@ -7017,9 +6733,43 @@ static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* iter_obj, Py_ssize_t ori
return 1;
}
-static void __Pyx_RaiseBufferFallbackError(void) {
- PyErr_SetString(PyExc_ValueError,
- "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
+static double __Pyx__PyObject_AsDouble(PyObject* obj) {
+ PyObject* float_value;
+#if CYTHON_COMPILING_IN_PYPY
+ float_value = PyNumber_Float(obj);
+#else
+ PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
+ if (likely(nb) && likely(nb->nb_float)) {
+ float_value = nb->nb_float(obj);
+ if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
+ PyErr_Format(PyExc_TypeError,
+ "__float__ returned non-float (type %.200s)",
+ Py_TYPE(float_value)->tp_name);
+ Py_DECREF(float_value);
+ goto bad;
+ }
+ } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
+#if PY_MAJOR_VERSION >= 3
+ float_value = PyFloat_FromString(obj);
+#else
+ float_value = PyFloat_FromString(obj, 0);
+#endif
+ } else {
+ PyObject* args = PyTuple_New(1);
+ if (unlikely(!args)) goto bad;
+ PyTuple_SET_ITEM(args, 0, obj);
+ float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
+ PyTuple_SET_ITEM(args, 0, 0);
+ Py_DECREF(args);
+ }
+#endif
+ if (likely(float_value)) {
+ double value = PyFloat_AS_DOUBLE(float_value);
+ Py_DECREF(float_value);
+ return value;
+ }
+bad:
+ return (double)-1;
}
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
@@ -7631,147 +7381,6 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
}
}
-#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
-static PyObject *__Pyx_GetStdout(void) {
- PyObject *f = PySys_GetObject((char *)"stdout");
- if (!f) {
- PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
- }
- return f;
-}
-static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
- int i;
- if (!f) {
- if (!(f = __Pyx_GetStdout()))
- return -1;
- }
- Py_INCREF(f);
- for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
- PyObject* v;
- if (PyFile_SoftSpace(f, 1)) {
- if (PyFile_WriteString(" ", f) < 0)
- goto error;
- }
- v = PyTuple_GET_ITEM(arg_tuple, i);
- if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
- goto error;
- if (PyString_Check(v)) {
- char *s = PyString_AsString(v);
- Py_ssize_t len = PyString_Size(v);
- if (len > 0) {
- switch (s[len-1]) {
- case ' ': break;
- case '\f': case '\r': case '\n': case '\t': case '\v':
- PyFile_SoftSpace(f, 0);
- break;
- default: break;
- }
- }
- }
- }
- if (newline) {
- if (PyFile_WriteString("\n", f) < 0)
- goto error;
- PyFile_SoftSpace(f, 0);
- }
- Py_DECREF(f);
- return 0;
-error:
- Py_DECREF(f);
- return -1;
-}
-#else
-static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
- PyObject* kwargs = 0;
- PyObject* result = 0;
- PyObject* end_string;
- if (unlikely(!__pyx_print)) {
- __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
- if (!__pyx_print)
- return -1;
- }
- if (stream) {
- kwargs = PyDict_New();
- if (unlikely(!kwargs))
- return -1;
- if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
- goto bad;
- if (!newline) {
- end_string = PyUnicode_FromStringAndSize(" ", 1);
- if (unlikely(!end_string))
- goto bad;
- if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
- Py_DECREF(end_string);
- goto bad;
- }
- Py_DECREF(end_string);
- }
- } else if (!newline) {
- if (unlikely(!__pyx_print_kwargs)) {
- __pyx_print_kwargs = PyDict_New();
- if (unlikely(!__pyx_print_kwargs))
- return -1;
- end_string = PyUnicode_FromStringAndSize(" ", 1);
- if (unlikely(!end_string))
- return -1;
- if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
- Py_DECREF(end_string);
- return -1;
- }
- Py_DECREF(end_string);
- }
- kwargs = __pyx_print_kwargs;
- }
- result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
- if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
- Py_DECREF(kwargs);
- if (!result)
- return -1;
- Py_DECREF(result);
- return 0;
-bad:
- if (kwargs != __pyx_print_kwargs)
- Py_XDECREF(kwargs);
- return -1;
-}
-#endif
-
-#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
-static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
- if (!f) {
- if (!(f = __Pyx_GetStdout()))
- return -1;
- }
- Py_INCREF(f);
- if (PyFile_SoftSpace(f, 0)) {
- if (PyFile_WriteString(" ", f) < 0)
- goto error;
- }
- if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
- goto error;
- if (PyFile_WriteString("\n", f) < 0)
- goto error;
- Py_DECREF(f);
- return 0;
-error:
- Py_DECREF(f);
- return -1;
- /* the line below is just to avoid C compiler
- * warnings about unused functions */
- return __Pyx_Print(f, NULL, 0);
-}
-#else
-static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
- int res;
- PyObject* arg_tuple = PyTuple_Pack(1, o);
- if (unlikely(!arg_tuple))
- return -1;
- res = __Pyx_Print(stream, arg_tuple, 1);
- Py_DECREF(arg_tuple);
- return res;
-}
-#endif
-
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
diff --git a/experiments/ml.pyx b/experiments/ml.pyx
index 9a786db..8dfea70 100644
--- a/experiments/ml.pyx
+++ b/experiments/ml.pyx
@@ -13,43 +13,21 @@ cdef DTYPE_t weight_success(int dist, int dt, DTYPE_t alpha, DTYPE_t delta,
DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
"""weight for successful infection, exponential time model"""
cdef DTYPE_t structural, temporal, result
- structural = delta ** (dist)
+ structural = dist * log(delta)
# structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- temporal = exp(-alpha * dt) * (1 - exp(-alpha))
- result = log(structural * temporal)
+ temporal = log(alpha) - alpha * dt
+ # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
+ result = structural + temporal
return result
-
-cdef DTYPE_t weight_success_power(int dist, int dt, DTYPE_t alpha, DTYPE_t delta,
- DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
- """weight for successful infection, power-law time model"""
- cdef DTYPE_t structural, temporal, result
- structural = delta ** (dist)
- # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01
- result = log(structural * temporal)
- return result
-
-
cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta,
DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
"""weight for failed infection, exponential time model"""
cdef DTYPE_t structural, temporal, result
- structural = delta ** (dist)
+ structural = delta ** dist
# structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
temporal = 1. - exp(-alpha * dt)
- #result = log(1. - structural)
- result = log(1. - structural * temporal)
- return result
-
-
-cdef DTYPE_t weight_failure_power(int dist, int dt, DTYPE_t alpha, DTYPE_t delta,
- DTYPE_t w1, DTYPE_t w2, DTYPE_t w3):
- """weight for failed infection, power-law time model"""
- cdef DTYPE_t structural, temporal, result
- structural = delta ** (dist)
- # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta)
- temporal = 1. - 1. / (1. + dt/alpha)**0.01
+ # temporal = 1. - 1. / (1. + dt/alpha)**0.01
result = log(1. - structural * temporal)
return result
@@ -60,7 +38,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
DTYPE_t beta, ll, beta2
list parents, failures, successes
n_roots, n_victims = len(root_victims), len(victims)
- n_nodes = n_roots + n_victims + len(non_victims)
+ n_nodes = 148152
cdef:
np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE)
np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE)
@@ -88,29 +66,31 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
probs_nv[i] = sum(failures)
# calculate log likelihood
- probs.sort(); probs = probs[::-1] # sort probs in descending order
- cdef:
- np.ndarray[DTYPE_t] cums = probs.cumsum()
- ll = probs_fail.sum()
- ll += probs_nv.sum()
+ # probs.sort(); probs = probs[::-1] # sort probs in descending order
+ # cdef:
+ # np.ndarray[DTYPE_t] cums = probs.cumsum()
+ ll = probs_fail.sum() # add probability that all edges to victims fail
+ ll += probs_nv.sum() # add probability that all edges to non_victims fail
+
+ max_i = -1
+ max_beta_add = float('-inf')
+ # iterate over all victim nodes to find the optimal threshold
+ for i in xrange(0, n_victims+1, 1):
+ roots = n_roots + n_victims - i
+ beta = float(roots)/float(n_nodes)
+ thresh = log(beta/(1.-beta))
+
+ # add probability for realized edges and subtract probability these edges fail
+ beta_add = (probs[probs>thresh]).sum()
+ print len(probs[probs>thresh])
+ # add probability for the seeds and non-seeds
+ beta_add += roots * log(beta) + (n_nodes-roots) * log(1 - beta)
+
+ if beta_add > max_beta_add:
+ max_i = i
+ max_beta_add = beta_add
- for i in xrange(n_victims - 1, 0, -1):
- # iterate over all victim nodes to find the optimal threshold
- roots = n_roots + n_victims - 1 - i
- beta = 1. / (1. + exp(-probs[i]))#exp(probs[i])#
- if beta > float(roots) / age:
- break
- else:
- print "alpha: {0}, delta: {1}. Everyone is a root".format(alpha, delta)
- roots = n_victims + n_roots
- i = -1
- beta = float(roots) / age
- for i in xrange(n_victims - 1, 0, -1):
- if probs[i] >= log(beta/(1.- beta)):
- break
- ll += age * log(1 - beta)
- if i >= 0:
- ll += cums[i]
- if roots > 0:
- ll += roots * log(beta) - roots * log(1 - beta)
+ ll += max_beta_add
+ roots = n_roots + n_victims - max_i
+ # print n_nodes, n_roots, n_victims, max_i, roots
return (beta, roots, ll)
diff --git a/experiments/ml.so b/experiments/ml.so
index 6708b62..687e6fc 100755
--- a/experiments/ml.so
+++ b/experiments/ml.so
Binary files differ
diff --git a/experiments/out.log b/experiments/out.log
index 21d7647..7651bb5 100644
--- a/experiments/out.log
+++ b/experiments/out.log
@@ -1,100 +1,50 @@
-1.0 0.01 0.000699524364831 11152 -93563.2077417
-1.0 0.11 0.000687104545585 10954 -126108.954721
-1.0 0.21 0.000637864353118 10169 -225778.622068
-1.0 0.31 0.000615784674457 9817 -438982.304589
-1.0 0.41 0.000594645891194 9480 -820866.792264
-0.0196078431373 0.01 0.000701217976547 11179 -93581.7583087
-0.0196078431373 0.11 0.000654675017552 10437 -125469.909855
-0.0196078431373 0.21 0.000561150015045 8946 -223797.998267
-0.0196078431373 0.31 0.0002813904502 4486 -432882.181737
-0.0196078431373 0.41 0.000184478224262 2941 -805629.546036
-0.00990099009901 0.01 0.000701217976547 11179 -93561.2440915
-0.00990099009901 0.11 0.000660947653535 10537 -125181.2304
-0.00990099009901 0.21 0.000615596495378 9814 -221949.68367
-0.00990099009901 0.31 0.000434380041827 6925 -428505.622634
-0.00990099009901 0.41 0.00014439608033 2302 -795422.075117
-0.00662251655629 0.01 0.000701217976547 11179 -93538.0800291
-0.00662251655629 0.11 0.000695384425082 11086 -124674.725165
-0.00662251655629 0.21 0.000613902883662 9787 -219695.063747
-0.00662251655629 0.31 0.000473395837642 7547 -422753.153539
-0.00662251655629 0.41 0.000128589037653 2050 -783092.670716
-0.00497512437811 0.01 0.000701217976547 11179 -93513.7830198
-0.00497512437811 0.11 0.000701217976547 11179 -124007.285557
-0.00497512437811 0.21 0.000621869131361 9914 -217270.221781
-0.00497512437811 0.31 0.000575137993287 9169 -416127.898633
-0.00497512437811 0.41 0.000119305536398 1902 -769645.108553
-0.00398406374502 0.01 0.000701217976547 11179 -93488.9577962
-0.00398406374502 0.11 0.000701217976547 11179 -123308.27892
-0.00398406374502 0.21 0.000644952431779 10282 -214713.10093
-0.00398406374502 0.31 0.000575953435965 9182 -409218.132116
-0.00398406374502 0.41 0.000117361019243 1871 -755582.995446
-0.00332225913621 0.01 0.000701217976547 11179 -93463.9651594
-0.00332225913621 0.11 0.000701217976547 11179 -122603.898157
-0.00332225913621 0.21 0.000701217976547 11179 -212027.615142
-0.00332225913621 0.31 0.000582916061906 9293 -402213.793166
-0.00332225913621 0.41 0.000116294671126 1854 -741201.966027
-0.002849002849 0.01 0.000701217976547 11179 -93439.0464125
-0.002849002849 0.11 0.000701217976547 11179 -121900.986303
-0.002849002849 0.21 0.000701217976547 11179 -209246.440515
-0.002849002849 0.31 0.000598221293705 9537 -395179.319043
-0.002849002849 0.41 0.000121626411712 1939 -726710.616309
-0.00249376558603 0.01 0.000701217976547 11179 -93414.3721791
-0.00249376558603 0.11 0.000701217976547 11179 -121204.383775
-0.00249376558603 0.21 0.000701217976547 11179 -206488.157401
-0.00249376558603 0.31 0.000624001827595 9948 -388154.241095
-0.00249376558603 0.41 0.000535306754795 8534 -711210.807876
-0.00221729490022 0.01 0.000701217976547 11179 -93390.0689254
-0.00221729490022 0.11 0.000701217976547 11179 -120517.699084
-0.00221729490022 0.21 0.000701217976547 11179 -203767.508539
-0.00221729490022 0.31 0.000701217976547 11179 -381143.230479
-0.00221729490022 0.41 0.000544025718811 8673 -696392.637558
-0.00199600798403 0.01 0.000701217976547 11179 -93366.2329151
-0.00199600798403 0.11 0.000701217976547 11179 -119843.710068
-0.00199600798403 0.21 0.000701217976547 11179 -201095.853981
-0.00199600798403 0.31 0.000701217976547 11179 -374174.567236
-0.00199600798403 0.41 0.000563219984919 8979 -681820.351781
-0.00181488203267 0.01 0.000701217976547 11179 -93342.9374684
-0.00181488203267 0.11 0.000701217976547 11179 -119184.562929
-0.00181488203267 0.21 0.000701217976547 11179 -198481.993876
-0.00181488203267 0.31 0.000701217976547 11179 -367356.474984
-0.00181488203267 0.41 0.000591948657722 9437 -667533.946527
-0.00166389351082 0.01 0.000701217976547 11179 -93320.2371523
-0.00166389351082 0.11 0.000701217976547 11179 -118541.881112
-0.00166389351082 0.21 0.000701217976547 11179 -195932.612778
-0.00166389351082 0.31 0.000701217976547 11179 -360706.658764
-0.00166389351082 0.41 0.000701217976547 11179 -653536.797837
-0.00153609831029 0.01 0.000701217976547 11179 -93298.1707271
-0.00153609831029 0.11 0.000701217976547 11179 -117916.840477
-0.00153609831029 0.21 0.000701217976547 11179 -193452.582772
-0.00153609831029 0.31 0.000701217976547 11179 -354238.043259
-0.00153609831029 0.41 0.000701217976547 11179 -639833.500691
-0.00142653352354 0.01 0.000701217976547 11179 -93276.7636012
-0.00142653352354 0.11 0.000701217976547 11179 -117310.233362
-0.00142653352354 0.21 0.000701217976547 11179 -191045.220734
-0.00142653352354 0.31 0.000701217976547 11179 -347959.448141
-0.00142653352354 0.41 0.000701217976547 11179 -626536.839343
-0.00133155792277 0.01 0.000701217976547 11179 -93256.0300389
-0.00133155792277 0.11 0.000701217976547 11179 -116722.528184
-0.00133155792277 0.21 0.000701217976547 11179 -188712.527865
-0.00133155792277 0.31 0.000701217976547 11179 -341876.217478
-0.00133155792277 0.41 0.000701217976547 11179 -613658.154993
-0.00124843945069 0.01 0.000701217976547 11179 -93235.9751664
-0.00124843945069 0.11 0.000701217976547 11179 -116153.925142
-0.00124843945069 0.21 0.000701217976547 11179 -186455.414117
-0.00124843945069 0.31 0.000701217976547 11179 -335990.810437
-0.00124843945069 0.41 0.000701217976547 11179 -601202.604835
-0.00117508813161 0.01 0.000701217976547 11179 -93216.5967646
-0.00117508813161 0.11 0.000701217976547 11179 -115604.407033
-0.00117508813161 0.21 0.000701217976547 11179 -184273.903387
-0.00117508813161 0.31 0.000701217976547 11179 -330303.342257
-0.00117508813161 0.41 0.000701217976547 11179 -589170.319862
-0.00110987791343 0.01 0.000701217976547 11179 -93197.8868346
-0.00110987791343 0.11 0.000701217976547 11179 -115073.784274
-0.00110987791343 0.21 0.000701217976547 11179 -182167.315678
-0.00110987791343 0.31 0.000701217976547 11179 -324812.065112
-0.00110987791343 0.41 0.000701217976547 11179 -577557.436029
-0.00105152471083 0.01 0.000701217976547 11179 -93179.8329341
-0.00105152471083 0.11 0.000701217976547 11179 -114561.733755
-0.00105152471083 0.21 0.000701217976547 11179 -180134.424545
-0.00105152471083 0.31 0.000701217976547 11179 -319513.784174
-0.00105152471083 0.41 0.000701217976547 11179 -566356.987655
+inf 0.01 0.00728306064042 1079 nan
+inf 0.11 0.00728306064042 1079 nan
+inf 0.21 0.00728306064042 1079 nan
+inf 0.31 0.00728306064042 1079 nan
+inf 0.41 0.00728306064042 1079 nan
+0.01 0.01 0.00728306064042 1079 -7632.33888826
+0.01 0.11 0.00728306064042 1079 -41145.4085812
+0.01 0.21 0.00728306064042 1079 -143816.774349
+0.01 0.31 0.00728306064042 1079 -362824.427206
+0.01 0.41 0.00728306064042 1079 -753873.18328
+0.005 0.01 0.00728306064042 1079 -7578.26678869
+0.005 0.11 0.00728306064042 1079 -39671.6480412
+0.005 0.21 0.00728306064042 1079 -138032.49228
+0.005 0.31 0.00728306064042 1079 -347783.849869
+0.005 0.41 0.00728306064042 1079 -721985.508852
+0.00333333333333 0.01 0.00728306064042 1079 -7522.44276229
+0.00333333333333 0.11 0.00728306064042 1079 -38127.923151
+0.00333333333333 0.21 0.00728306064042 1079 -131943.601486
+0.00333333333333 0.31 0.00728306064042 1079 -331924.789171
+0.00333333333333 0.41 0.00728306064042 1079 -688355.043571
+0.0025 0.01 0.00728306064042 1079 -7467.51417822
+0.0025 0.11 0.00728306064042 1079 -36599.8359599
+0.0025 0.21 0.00728306064042 1079 -125903.505379
+0.0025 0.31 0.00728306064042 1079 -316183.068106
+0.0025 0.41 0.00728306064042 1079 -654979.438431
+0.002 0.01 0.00728306064042 1079 -7414.70185168
+0.002 0.11 0.00728306064042 1079 -35125.3347484
+0.002 0.21 0.00728306064042 1079 -120067.848333
+0.002 0.31 0.00728306064042 1079 -300970.34788
+0.002 0.41 0.00728306064042 1079 -622737.297292
+0.00166666666667 0.01 0.00728306064042 1079 -7364.63045747
+0.00166666666667 0.11 0.00728306064042 1079 -33723.8769361
+0.00166666666667 0.21 0.00728306064042 1079 -114516.615274
+0.00166666666667 0.31 0.00728306064042 1079 -286498.257545
+0.00166666666667 0.41 0.00728306064042 1079 -592079.644373
+0.00142857142857 0.01 0.00728306064042 1079 -7317.59743719
+0.00142857142857 0.11 0.00728306064042 1079 -32405.1880251
+0.00142857142857 0.21 0.00728306064042 1079 -109290.356131
+0.00142857142857 0.31 0.00728306064042 1079 -272874.512749
+0.00142857142857 0.41 0.00728306064042 1079 -563235.857483
+0.00125 0.01 0.00728306064042 1079 -7273.68766807
+0.00125 0.11 0.00728306064042 1079 -31172.6518115
+0.00125 0.21 0.00728306064042 1079 -104403.890399
+0.00125 0.31 0.00728306064042 1079 -260138.956484
+0.00125 0.41 0.00728306064042 1079 -536290.339785
+0.00111111111111 0.01 0.00728306064042 1079 -7232.84785268
+0.00111111111111 0.11 0.00728306064042 1079 -30025.4645403
+0.00111111111111 0.21 0.00728306064042 1079 -99854.9698943
+0.00111111111111 0.31 0.00728306064042 1079 -248286.311147
+0.00111111111111 0.41 0.00728306064042 1079 -511230.928521
diff --git a/experiments/process.py b/experiments/process.py
index 8ebe953..68c3507 100644
--- a/experiments/process.py
+++ b/experiments/process.py
@@ -11,11 +11,16 @@ if __name__ == "__main__":
sys.exit("usage: {0} <file>".format(sys.argv[0]))
root_victims, victims, non_victims, age = load(open(sys.argv[1]))
- alphas = 1. / np.arange(1., 1000., 50.) # parameter of the time component
+ alphas = 1. / np.arange(0., 1000., 100.) # parameter of the time component
deltas = np.arange(0.01, 0.5, 0.1) # parameter of the structural component
with open("out.log", "w") as fh:
for alpha, delta in product(alphas, deltas):
beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta)
- print "\t".join(map(str, [1/alpha, delta, beta, roots, ll, exp(ll)]))
+ print "\t".join(map(str, [1/alpha, delta, beta, roots, ll]))
fh.write("\t".join(map(str, [alpha, delta, beta, roots, ll])) + "\n")
fh.flush()
+
+ # alpha = 100.
+ # delta = 0.2
+ # beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta)
+ # print "\t".join(map(str, [1./alpha, delta, beta, roots, ll])) \ No newline at end of file