Examples of Frequency


Examples of com.clowtown.mealplanner.policy.Frequency

  }
  public void actionPerformed(ActionEvent arg0) {
    super.actionPerformed(arg0);
         System.out.println(arg0.getActionCommand());
    if("OK".equalsIgnoreCase(arg0.getActionCommand())){
      Frequency f = dialog.getChosenFrequency();
      ArrayList<Season> s = dialog.getChosenSeasons();
      PolicyEnum[] pe = s.toArray(new PolicyEnum[]{});
      p = new MenuPolicy(pe);
      p.editPolicy(MenuPolicy.ADD, f);
      fireEditingStopped();
View Full Code Here

Examples of com.google.ical.values.Frequency

    rrule.setName(rnd.nextInt(4) < 1 ? "EXRULE" : "RRULE");
    // pick a frequency
    // This is stretching the definition of well formed, but we don't do
    // more frequently than daily.
    // TODO: allow more frequently than DAILY. BEFORE SUBMIT
    Frequency freq = FREQS[rnd.nextInt(FREQS.length)];
    rrule.setFreq(freq);

    if (rnd.nextBoolean()) {
      // biased towards the beginning of the week
      rrule.setWkSt(WDAYS[((int) Math.abs(rnd.nextGaussian() / 3) * 7) % 7]);
    }

    if (rnd.nextBoolean()) {
      if (rnd.nextBoolean()) {
        rrule.setCount(1 + ((int) (Math.abs(rnd.nextGaussian() * 10))));
      } else {
        rrule.setUntil(monkeySeeDateValue(maybeNot(timed)));
      }
    }

    rrule.setInterval(
        (int) Math.min(0, Math.abs(rnd.nextGaussian() - .5) * 3) + 1);

    int sparsity = 2 + rnd.nextInt(6);

    boolean allowsByDay = freq.compareTo(Frequency.WEEKLY) >= 0;
    if (0 == rnd.nextInt(sparsity) && maybeNot(allowsByDay)) {
      rrule.setByDay(Arrays.asList(monkeySeeWeekdayNumList(freq)));
    }

    if (0 == rnd.nextInt(sparsity)) {
View Full Code Here

Examples of com.opengamma.financial.convention.frequency.Frequency

    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    final DayCount thirty360 = DayCountFactory.INSTANCE.getDayCount("30/360");
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);

    final ExternalId dk = ExternalSchemes.financialRegionId("NO");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

    super();
    this.values = values;
  }
 
  Frequency make(IList dataValues){
    Frequency freq = new Frequency();
    for(IValue v : dataValues){
      if(v instanceof INumber)
        freq.addValue(new ComparableValue((INumber)v));
      else if(v instanceof IString)
        freq.addValue(new ComparableValue((IString)v));
      else
        throw RuntimeExceptionFactory.illegalArgument(v,null, null);
    }
    return freq;
  }
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

            randomData.nextInt(4, 3);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException ex) {
            // ignored
        }
        Frequency freq = new Frequency();
        int value = 0;
        for (int i = 0; i < smallSampleSize; i++) {
            value = randomData.nextInt(0, 3);
            assertTrue("nextInt range", (value >= 0) && (value <= 3));
            freq.addValue(value);
        }
        long[] observed = new long[4];
        for (int i = 0; i < 4; i++) {
            observed[i] = freq.getCount(i);
        }

        /*
         * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
         * for alpha = .01
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

            randomData.nextLong(4, 3);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException ex) {
            // ignored
        }
        Frequency freq = new Frequency();
        long value = 0;
        for (int i = 0; i < smallSampleSize; i++) {
            value = randomData.nextLong(0, 3);
            assertTrue("nextInt range", (value >= 0) && (value <= 3));
            freq.addValue(value);
        }
        long[] observed = new long[4];
        for (int i = 0; i < 4; i++) {
            observed[i] = freq.getCount(i);
        }

        /*
         * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
         * for alpha = .01
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

            randomData.nextSecureLong(4, 3);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException ex) {
            // ignored
        }
        Frequency freq = new Frequency();
        long value = 0;
        for (int i = 0; i < smallSampleSize; i++) {
            value = randomData.nextSecureLong(0, 3);
            assertTrue("nextInt range", (value >= 0) && (value <= 3));
            freq.addValue(value);
        }
        long[] observed = new long[4];
        for (int i = 0; i < 4; i++) {
            observed[i] = freq.getCount(i);
        }

        /*
         * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
         * for alpha = .01
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

            randomData.nextSecureInt(4, 3);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException ex) {
            // ignored
        }
        Frequency freq = new Frequency();
        int value = 0;
        for (int i = 0; i < smallSampleSize; i++) {
            value = randomData.nextSecureInt(0, 3);
            assertTrue("nextInt range", (value >= 0) && (value <= 3));
            freq.addValue(value);
        }
        long[] observed = new long[4];
        for (int i = 0; i < 4; i++) {
            observed[i] = freq.getCount(i);
        }

        /*
         * Use ChiSquare dist with df = 4-1 = 3, alpha = .001 Change to 11.34
         * for alpha = .01
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

            randomData.nextPoisson(0);
            fail("zero mean -- expecting IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // ignored
        }
        Frequency f = new Frequency();
        for (int i = 0; i < largeSampleSize; i++) {
            try {
                f.addValue(randomData.nextPoisson(4.0d));
            } catch (Exception ex) {
                fail(ex.getMessage());
            }
        }
        long cumFreq = f.getCount(0) + f.getCount(1) + f.getCount(2)
                + f.getCount(3) + f.getCount(4) + f.getCount(5);
        long sumFreq = f.getSumFreq();
        double cumPct = Double.valueOf(cumFreq).doubleValue()
                / Double.valueOf(sumFreq).doubleValue();
        assertEquals("cum Poisson(4)", cumPct, 0.7851, 0.2);
        try {
            randomData.nextPoisson(-1);
View Full Code Here

Examples of org.apache.commons.math.stat.Frequency

        // Generate sample values
        int sampleSize = 1000;        // Number of deviates to generate
        int minExpectedCount = 7;     // Minimum size of expected bin count
        long maxObservedValue = 0;
        double alpha = 0.001;         // Probability of false failure
        Frequency frequency = new Frequency();
        for (int i = 0; i < sampleSize; i++) {
            long value = randomData.nextPoisson(mean);
            if (value > maxObservedValue) {
                maxObservedValue = value;
            }
            frequency.addValue(value);
        }

        /*
         *  Set up bins for chi-square test.
         *  Ensure expected counts are all at least minExpectedCount.
         *  Start with upper and lower tail bins.
         *  Lower bin = [0, lower); Upper bin = [upper, +inf).
         */
        PoissonDistribution poissonDistribution = new PoissonDistributionImpl(mean);
        int lower = 1;
        while (poissonDistribution.cumulativeProbability(lower - 1) * sampleSize < minExpectedCount) {
            lower++;
        }
        int upper = (int) (5 * mean)// Even for mean = 1, not much mass beyond 5
        while ((1 - poissonDistribution.cumulativeProbability(upper - 1)) * sampleSize < minExpectedCount) {
            upper--;
        }

        // Set bin width for interior bins.  For poisson, only need to look at end bins.
        int binWidth = 1;
        boolean widthSufficient = false;
        double lowerBinMass = 0;
        double upperBinMass = 0;
        while (!widthSufficient) {
            lowerBinMass = poissonDistribution.cumulativeProbability(lower, lower + binWidth - 1);
            upperBinMass = poissonDistribution.cumulativeProbability(upper - binWidth + 1, upper);
            widthSufficient = Math.min(lowerBinMass, upperBinMass) * sampleSize >= minExpectedCount;
            binWidth++;
        }

        /*
         *  Determine interior bin bounds.  Bins are
         *  [1, lower = binBounds[0]), [lower, binBounds[1]), [binBounds[1], binBounds[2]), ... ,
         *    [binBounds[binCount - 2], upper = binBounds[binCount - 1]), [upper, +inf)
         *
         */
        List<Integer> binBounds = new ArrayList<Integer>();
        binBounds.add(lower);
        int bound = lower + binWidth;
        while (bound < upper - binWidth) {
            binBounds.add(bound);
            bound += binWidth;
        }
        binBounds.add(bound);
        binBounds.add(upper);

        // Compute observed and expected bin counts
        final int binCount = binBounds.size() + 1;
        long[] observed = new long[binCount];
        double[] expected = new double[binCount];

        // Bottom bin
        observed[0] = 0;
        for (int i = 0; i < lower; i++) {
            observed[0] += frequency.getCount(i);
        }
        expected[0] = poissonDistribution.cumulativeProbability(lower - 1) * sampleSize;

        // Top bin
        observed[binCount - 1] = 0;
        for (int i = upper; i <= maxObservedValue; i++) {
            observed[binCount - 1] += frequency.getCount(i);
        }
        expected[binCount - 1] = (1 - poissonDistribution.cumulativeProbability(upper - 1)) * sampleSize;

        // Interior bins
        for (int i = 1; i < binCount - 1; i++) {
            observed[i] = 0;
            for (int j = binBounds.get(i - 1); j < binBounds.get(i); j++) {
                observed[i] += frequency.getCount(j);
            } // Expected count is (mass in [binBounds[i], binBounds[i+1])) * sampleSize
            expected[i] = (poissonDistribution.cumulativeProbability(binBounds.get(i) - 1) -
                poissonDistribution.cumulativeProbability(binBounds.get(i - 1) -1)) * sampleSize;
        }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.