milindvdamle opened a new pull request #30533:
URL: https://github.com/apache/spark/pull/30533
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR:
https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g.,
'[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a
faster review.
7. If you want to add a new configuration, please read the guideline first
for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section
is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster
reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class
hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other
DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
The current example script (pi.py) produces an approximate value for pi
based on randomly-chosen points and is neither deterministic nor accurate. A
new example is needed to fix this issue.
https://en.wikipedia.org/wiki/Approximations_of_%CF%80
http://oeis.org/wiki/Pi#Decimal_expansion_of_.CF.80.E2.80.8A2
https://mathworld.wolfram.com/PiFormulas.html

This new example calculates pi using a partial sum of series that implements
the formula shown in the attached image.
### Does this PR introduce _any_ user-facing change?
Yes, it provides an additional example python script (series-pi.py) to
calculate pi.
### How was this patch tested?
The script accepts two optional command-line parameters. The first parameter
specifies the number of terms to use to approximate pi. The second parameter
specifies the number of Spark partitions to use to calculate the result.
The script was run multiple times with 10 million terms, 100 million terms,
500 million terms and 1 billion terms each as the value of the first parameter.
The resulting approximate value for pi was verified against the published/known
approximation (https://oeis.org/A000796).
Two things were noted and verified:
1. For the same number of terms provided, it was verified that each run of
the script produced a deterministic value for pi.
2. Increasing the number of terms (first parameter) produced a more accurate
approximation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]