Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-330

F-distribution: add density-function (through HasDensity<Double>-interface)

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      I've added the density function for the F-distribution.

      Tested from R with:
      > df(1, 1, 1)
      [1] 0.1591549
      > df(1, 5, 2)
      [1] 0.3080008
      > df(1, 100, 1)
      [1] 0.2407659
      > df(1, 50, 200)
      [1] 1.777891

      The result with this new density-function:
      FDistributionImpl F1 = new FDistributionImpl(1, 1);
      FDistributionImpl F2 = new FDistributionImpl(5, 2);
      FDistributionImpl F3 = new FDistributionImpl(100, 1);
      FDistributionImpl F4 = new FDistributionImpl(50, 200);

      F1.density(1.0); // gives 0.1591549430918953
      F2.density(1.0); // gives 0.308000821694066
      F3.density(1.0); // gives 0.2407658969285279
      F4.density(1.0); // gives 1.7778909151036544

      Some numeric instability may occur because it's the log density that's calculated, and then the result is the exponential function applied to this result.

        Attachments

        1. patchfile
          3 kB
          Mikkel Meyer Andersen

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikl Mikkel Meyer Andersen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified