Skip to content

Commit

Permalink
prevented generation of zero amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
nimar committed Mar 10, 2015
1 parent b23b393 commit ece1da8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
7 changes: 7 additions & 0 deletions description.tex
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,13 @@ \subsection{Evaluation}
Mag Errors mean 0.2 std 0.1
\end{verbatim}

\subsection{Metric and Submission}

This problem does not require a performance profile. Teams should report
the metrics output by the evaluation script at the point where their
solution halts. Teams should also report the CPU time consumed by their
solution, in milliseconds.

\begin{appendices}

\section{Spherical Geometry Functions}
Expand Down
26 changes: 20 additions & 6 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from scipy.stats import gamma, norm, invgamma, poisson, uniform, expon,\
bernoulli, laplace, cauchy
from numpy import array, sqrt, log, exp, pi, arcsin, degrees, seterr
from numpy import array, sqrt, log, exp, pi, arcsin, degrees, seterr, isinf
seterr(all='raise')
from collections import namedtuple

Expand Down Expand Up @@ -209,11 +209,22 @@ def sample_episodes(numepisodes, physics):
detslow = laplace.rvs(compute_slowness(dist) + physics.mu_s[stanum],
physics.theta_s[stanum])

detamp = exp(norm.rvs(physics.mu_a0[stanum]
+ physics.mu_a1[stanum] * event.mag
+ physics.mu_a2[stanum] * dist,
physics.sigma_a[stanum]))

while True:
# resample if the detection amplitude is infinite
try:
detamp = exp(norm.rvs(physics.mu_a0[stanum]
+ physics.mu_a1[stanum] * event.mag
+ physics.mu_a2[stanum] * dist,
physics.sigma_a[stanum]))

except FloatingPointError:
continue

# disallow zero or infinite amplitudes
if detamp == 0 or isinf(detamp):
continue
break

truedets.append(len(detections))
detections.append(Detection(stanum, dettime, detaz, detslow,
detamp))
Expand Down Expand Up @@ -243,6 +254,9 @@ def sample_episodes(numepisodes, physics):
except FloatingPointError:
continue

# disallow zero or infinite amplitudes
if detamp == 0 or isinf(detamp):
continue
break

detections.append(Detection(stanum, dettime, detaz, detslow, detamp))
Expand Down

0 comments on commit ece1da8

Please sign in to comment.