Class PiEstimation

  • All Implemented Interfaces:
    Serializable

    public class PiEstimation
    extends Object
    implements Serializable
    Estimates the value of Pi using the Monte Carlo method. The area of a circle is Pi * R^2, R being the radius of the circle The area of a square is 4 * R^2, where the length of the square's edge is 2*R.

    Thus Pi = 4 * (area of circle / area of square).

    The idea is to find a way to estimate the circle to square area ratio. The Monte Carlo method suggests collecting random points (within the square) and then counting the number of points that fall within the circle

    
     x = Math.random()
     y = Math.random()
    
     x * x + y * y < 1
     

    Note: All Flink DataSet APIs are deprecated since Flink 1.18 and will be removed in a future Flink major version. You can still build your application in DataSet, but you should move to either the DataStream and/or Table API. This class is retained for testing purposes.

    See Also:
    Serialized Form
    • Constructor Detail

      • PiEstimation

        public PiEstimation()