diff options
| author | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-07-14 09:48:16 -0400 |
|---|---|---|
| committer | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-07-14 09:48:16 -0400 |
| commit | 37c23e0d1fcbdee116856d59c0dab98686e265ae (patch) | |
| tree | 673bb9e59927f9cccd8a78ad18f2017ebd90af2d /experiments/ml.pyx | |
| parent | 034c71328460d460deef74bf591c8d6cd28d5f93 (diff) | |
| download | criminal_cascades-37c23e0d1fcbdee116856d59c0dab98686e265ae.tar.gz | |
a few experiments
Diffstat (limited to 'experiments/ml.pyx')
| -rw-r--r-- | experiments/ml.pyx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/experiments/ml.pyx b/experiments/ml.pyx index 7eca30a..91536b5 100644 --- a/experiments/ml.pyx +++ b/experiments/ml.pyx @@ -10,7 +10,7 @@ cdef DTYPE_t weight_success(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, DTYP DTYPE_t t_scale, 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 = delta ** (dist**1) # structural = delta/(1. + 1./(w1*lmbda) + 1./(w2*lmbda) + 1./(w3*lmbda)) temporal = log(exp(alpha/t_scale)-1.) - alpha*dt/t_scale # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 @@ -21,11 +21,12 @@ cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, DTYP DTYPE_t t_scale, 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**1) # structural = delta/(1. + 1./(w1*lmbda) + 1./(w2*lmbda) + 1./(w3*lmbda)) temporal = exp(-alpha * dt/t_scale) # temporal = 1. - 1. / (1. + dt/alpha)**0.01 result = log(1. - structural + structural * temporal) + # if dt>100: result=0 return result def ml(dict root_victims, dict victims, dict non_victims, @@ -65,6 +66,7 @@ def ml(dict root_victims, dict victims, dict non_victims, probs[i] = prob parent_dists[i] = dists[l] parent_dts[i] = dts[l] + # probs_fail[i] = failures[l] # loop through non-victims for i, parents in enumerate(non_victims.itervalues()): |
