calculate pi
i need to know pi
the most convoluted way possible
node
redis-server
node index.js s3://lab.userhostilesoftware.com/felix/sources/1k.csv
node index.js s3://lab.userhostilesoftware.com/felix/sources/1mm.csv
node index.js s3://lab.userhostilesoftware.com/felix/sources/10mm.csv
These files look like this:
0.25008359797885515,-0.12253391152031234
0.25671068645112394,0.6236567284188683
0.5489052378982133,0.3628287655159652
-0.7161118031711806,0.6128895667451084
-0.3556614742846562,-0.5742847542854475
-0.7107119171413923,-0.3800788981027228
0.821927211540268,-0.6761022190782098
0.8972711532788986,0.32230451489339096
0.3831193475614978,0.8239172304833862
0.8370952005042178,0.7065482115404758
Following the columns from left to right:
- CSV file of random [x, y] values is stored on S3
- ƒ(:one:) parses CSV into [x, y] tuples and emits the tuple to a single stream
- ƒ(:two:) simply applies a fan-out to the stream into n partitions
- ƒ(:three:) spawns an indepenent processes per partition that calculate if the [x, y] tuple is inside the circle, maintain a running count of the number of points in the circle and total points, and finally calculates an approximation of pi
- f(:four:) aggregates the results of the partitions and calculates a running average of the pi approximation onto a final stream whose last value should converge to pi