Class PiEstimation
- java.lang.Object
-
- org.apache.flink.examples.java.misc.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 < 1Note: 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPiEstimation.SamplerSampler randomly emits points that fall within a square of edge x * y.static classPiEstimation.SumReducerSimply sums up all long values.
-
Constructor Summary
Constructors Constructor Description PiEstimation()
-