Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/src/main/python/pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
if __name__ == "__main__":
"""
Usage: pi [partitions]
Monte Carlo method is used to estimate Pi in the below example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below example -> example below

"""
spark = SparkSession\
.builder\
.appName("PythonPi")\
.getOrCreate()


# If no arguments are passed(i.e. `len(sys.argv) < = 1` )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't visible to end users, so don't know if this matters. It's already documented in the usage. I am not sure this meaningfully helps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think we should expect folks to read the examples in addition to running them. That being said I don't think we need this comment specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the first example on the spark doc and I wanted to know how the pi calculation was done. There was no mention of what algorithm is used for it, so took me a while to figure out the Monte-Carlo estimator was used and the logic is randomly generating over 100000 points to finally estimate the Pi value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srowen Added a line to the index.md as well, I think it would help the curious ones know what algorithm is used and why an argument(i.e. 10) is passed.

# while calling this script, the default value assigned is 2
partitions = int(sys.argv[1]) if len(sys.argv) > 1 else 2
n = 100000 * partitions

Expand Down