Пример #1
0
 /**
  * This draws a random list of ruptures. Non-poisson sources are not yet implemented
  *
  * @return
  */
 public ArrayList<ProbEqkRupture> drawRandomEqkRuptures() {
   ArrayList<ProbEqkRupture> rupList = new ArrayList();
   // System.out.println("New Rupture")
   if (isPoissonian) {
     for (int r = 0; r < getNumRuptures(); r++) {
       ProbEqkRupture rup = getRupture(r);
       // if(rup.getProbability() > 0.99)
       // System.out.println("Problem!");
       double expected = -Math.log(1 - rup.getProbability());
       // double rand = 0.99;
       double rand = Math.random();
       double sum = 0;
       double factoral = 1;
       int maxNum = (int) Math.round(10 * expected) + 2;
       int num;
       for (num = 0; num < maxNum; num++) {
         if (num != 0) factoral *= num;
         double prob = Math.pow(expected, num) * Math.exp(-expected) / factoral;
         sum += prob;
         if (rand <= sum) break;
       }
       for (int i = 0; i < num; i++) rupList.add((ProbEqkRupture) rup.clone());
       /*
        * if(num >0) System.out.println("expected="+expected+"\t"+
        * "rand="+rand+"\t"+ "num="+num+"\t"+ "mag="+rup.getMag());
        */
     }
   } else
     throw new RuntimeException(
         "drawRandomEqkRuptures(): Non poissonsources are not yet supported");
   return rupList;
 }
Пример #2
0
 /**
  * Get rupture probability within a region. It first checks whether the end points are within
  * region. If yes, then rupture is considered within the region Else It finds the fraction of
  * rupture FAULT TRACE (not the surface) points within the region and then adjusts the probability
  * accordingly.
  *
  * @param tempRup
  * @param region
  * @return
  */
 private double getApproxRupProbWithinRegion(ProbEqkRupture tempRup, Region region) {
   int numLocsInside = 0;
   int totPoints = 0;
   if (region != null) {
     // get num surface points inside region
     EvenlyGriddedSurfaceAPI rupSurface = tempRup.getRuptureSurface();
     Location loc1 = rupSurface.getLocation(0, 0);
     Location loc2 = rupSurface.getLocation(0, rupSurface.getNumCols() - 1);
     // if both surface points are within region, rupture is considered
     // within region
     if (region.contains(loc1) && region.contains(loc2)) {
       numLocsInside = 1;
       totPoints = numLocsInside;
     } else { // if both points are not within region, calculate rupProb
       Iterator locIt = rupSurface.getColumnIterator(0);
       while (locIt.hasNext()) {
         if (region.contains((Location) locIt.next())) ++numLocsInside;
         ++totPoints;
       }
     }
   } else {
     numLocsInside = 1;
     totPoints = numLocsInside;
   }
   if (isPoissonian)
     return Math.log(1 - tempRup.getProbability() * numLocsInside / (double) totPoints);
   else return tempRup.getProbability() * numLocsInside / (double) totPoints;
 }
Пример #3
0
 /**
  * This computes the total probability of all rutures great than or equal to the given mangitude
  *
  * @return
  */
 public double computeTotalProbAbove(double mag, Region region) {
   double totProb = 0;
   ProbEqkRupture tempRup;
   for (int i = 0; i < getNumRuptures(); i++) {
     tempRup = getRupture(i);
     if (tempRup.getMag() < mag) continue;
     totProb += getRupProbWithinRegion(tempRup, region);
   }
   if (isPoissonian) return 1 - Math.exp(totProb);
   else return totProb;
 }
Пример #4
0
 /**
  * Get rupture probability within a region. It finds the fraction of rupture surface points within
  * the region and then adjusts the probability accordingly.
  *
  * @param tempRup
  * @param region
  * @return
  */
 private double getRupProbWithinRegion(ProbEqkRupture tempRup, Region region) {
   int numLocsInside = 0;
   int totPoints = 0;
   if (region != null) {
     // get num surface points inside region
     Iterator locIt = tempRup.getRuptureSurface().getLocationsIterator();
     while (locIt.hasNext()) {
       if (region.contains((Location) locIt.next())) ++numLocsInside;
       ++totPoints;
     }
   } else {
     numLocsInside = 1;
     totPoints = numLocsInside;
   }
   if (isPoissonian)
     return Math.log(1 - tempRup.getProbability() * numLocsInside / (double) totPoints);
   else return tempRup.getProbability() * numLocsInside / (double) totPoints;
 }
Пример #5
0
 /**
  * this function can be used if a clone is wanted instead of handle to class variable Subsequent
  * calls to this function will not affect the result got previously. This is in contrast with the
  * getRupture(int i) function
  *
  * @param nRupture
  * @return the clone of the probEqkRupture
  */
 public ProbEqkRupture getRuptureClone(int nRupture) {
   ProbEqkRupture eqkRupture = getRupture(nRupture);
   ProbEqkRupture eqkRuptureClone = (ProbEqkRupture) eqkRupture.clone();
   return eqkRuptureClone;
 }