[{"data":1,"prerenderedAt":338},["ShallowReactive",2],{"project-8159010":3},{"id":4,"name":5,"line":5,"line_source":6,"title":7,"url":8,"domain":9,"maker":10,"posted_at":11,"year":12,"points":13,"comments":14,"rank_in_year":15,"shown_in_year":16,"top":17,"tier":18,"category":19,"subcategory":20,"format":21,"keywords":22,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":34,"aspects":35,"strip":43,"post_text":45,"what":46,"said":85,"maker_in_thread":156,"shape":165,"grid":170,"attempts":301,"same_week":302,"maker_shows":39,"maker_hidden":330,"reader_version":331,"card":332},"8159010","Pi Approximation using Monte Carlo","title","Show HN: Pi Approximation using Monte Carlo","http:\u002F\u002Fmontepie.herokuapp.com","montepie.herokuapp.com","krat0sprakhar",1407651044,2014,39,55,810,2272,36,"shown","learning_science","interactive math visualization","web_app",[23,24,25,26],"monte carlo","pi approximation","monte carlo simulation","javascript visualization","curious",-0.072,{"positive":30,"neutral":31,"mixed":32,"critical":33},3,19,0,4,26,{"design":36,"performance":38,"execution":40,"idea":41,"docs":42},{"positive":37,"critical":32},1,{"positive":32,"critical":39},2,{"positive":32,"critical":32},{"positive":37,"critical":39},{"positive":32,"critical":32},[44,32,30,44,32,30,30,30,30,30,37,30,30,37,32,32,32,32,32,32,32,32,32,32,32,37,32,32,30,30,30,30,32,32,44,37,30,30,30,32],5,null,{"problem":47,"audience":54,"pricing":45,"motivation":66,"time_to_build":45,"stack":70,"openness":83,"stage":84,"team_size":83},{"value":48,"source":49,"evidence":50},"Demonstrates how Monte Carlo sampling can approximate pi","maker",[51],{"id":52,"by":10,"text":53},"8159071","Hi HN! This is a small hack that I created over the weekend. I learnt about the Monte Carlo method while doing Princeton's Functional Programming course[0] in OCaml[1] as one of…",{"value":55,"source":56,"evidence":57},"Students and people learning Monte Carlo methods","inferred",[58,62],{"id":59,"by":60,"text":61},"8159350","MrQuincle","Do not underestimate the value of these visualizations. They reach 1000s of kids, students, and who-knows, adults fooling around on Sundays. So, perhaps you can turn this around,…",{"id":63,"by":64,"text":65},"8159240","adwn","Monte Carlo methods are never \"seriously\" used to approximate pi – there are algorithms which converge much, much faster. This here, however, is not a \"serious\" attempt at…",{"value":67,"source":49,"evidence":68},"Weekend hack after learning Monte Carlo in Princeton's functional programming course",[69],{"id":52,"by":10,"text":53},[71,79],{"value":72,"source":73,"evidence":74},"JavaScript","commenter",[75],{"id":76,"by":77,"text":78},"8159522","nemetroid","> not quite possible in the browser! It's not the browser (or JS) that's slow, it's all the animations and stuff. If you write Javascript to do only what the OCaml code does, it…",{"value":80,"source":49,"evidence":81},"OCaml",[82],{"id":52,"by":10,"text":53},"unknown","prototype",{"praise":86,"objections":91,"requests":111,"questions":127,"alternatives":139},[87],{"value":88,"source":73,"evidence":89},"Valuable for teaching and education",[90],{"id":59,"by":60,"text":61},[92,103],{"value":93,"source":73,"evidence":94},"Converges slowly; estimate often far from pi at low iteration counts",[95,99],{"id":96,"by":97,"text":98},"8159079","clemsen","Nice visualization. After playing with it for a while, the number never really converged to Pi. The value even reached 3.135 after 10000 iterations. Do you have any measure how…",{"id":100,"by":101,"text":102},"8159544","Karellen","I got 3.1544 after 10000 iterations, which also didn't match my intuition of how quickly it \"should\" converge. So I decided to knock up a quick deterministic version in C that…",{"value":104,"source":73,"evidence":105},"Monte Carlo is an inefficient way to compute pi",[106,110],{"id":107,"by":108,"text":109},"8159136","wfunction","I will never understand why people think Monte Carlo is such a neat solution. There is nothing random about pi. Why didn't you just pick the center of the square, use that to…",{"id":63,"by":64,"text":65},[112,119,123],{"value":113,"source":73,"evidence":114},"Graph of pi approximation versus n",[115],{"id":116,"by":117,"text":118},"8159555","gus_massa","Nice visualization! Some UI comments I think the reset button should be smaller (you usually don't want to reset the simulation). I expected that the number in the upper right…",{"value":120,"source":73,"evidence":121},"Error estimates or bounds",[122],{"id":116,"by":117,"text":118},{"value":124,"source":73,"evidence":125},"Advanced mode and smaller reset button",[126],{"id":116,"by":117,"text":118},[128,135],{"value":129,"source":73,"evidence":130},"Why does the estimate overshoot more than undershoot?",[131],{"id":132,"by":133,"text":134},"8159098","skykooler","I notice that it seems to overshoot more than it undershoots. Any idea why this is?",{"value":136,"source":73,"evidence":137},"How many iterations are needed for stable digits?",[138],{"id":96,"by":97,"text":98},[140,145],{"value":141,"source":73,"evidence":142},"Deterministic grid sampling",[143,144],{"id":100,"by":101,"text":102},{"id":107,"by":108,"text":109},{"value":146,"source":73,"evidence":147},"Quasi-Monte Carlo with Sobol sequences",[148,152],{"id":149,"by":150,"text":151},"8159141","brotchie","It would be interesting to see how quickly a quasi-random, low-discrepancy sequence converges to PI (e.g. a Sobol Sequence).",{"id":153,"by":154,"text":155},"8160248","mturmon","The comment has a point. It is possible that the particular deterministic rule that chooses points could interact with the shape (quarter circle). In this case, the error would…",{"comments":44,"answered":37,"key":157},[158,161,162],{"id":159,"text":160},"8160281","Thanks for the great suggestions. Will add these in soon!",{"id":52,"text":53},{"id":163,"text":164},"8159172","Wow! Nicely done. The idea of showing relative error is pretty cool :D",{"commenters":166,"max_depth":167,"maker_replies":44,"first_comment_mins":168,"lifespan_hours":169},28,8,43,262,[171,173,175,177,180,183,184,186,189,192,195,198,200,203,205,207,209,212,213,215,219,223,225,228,230,233,235,237,239,241,243,244,246,248,251,253,255,256,258,261,264,266,268,270,272,274,276,278,280,282,286,288,291,295,297],[116,32,44,172,117,32],"project\u002Fpositive\u002Fdesign",[159,32,32,174,10,37],"maker\u002Fpositive\u002Fnone",[52,37,32,176,10,37],"project\u002Fneutral\u002Fnone",[178,37,30,176,179,32],"8159122","Goopplesoft",[181,37,44,174,182,32],"8159154","fphilipe",[163,37,32,174,10,37],[76,37,30,185,77,32],"project\u002Fneutral\u002Fperformance",[187,39,30,188,60,32],"8159212","project\u002Fneutral\u002Fexecution",[190,39,30,188,191,32],"8159238","afafsd",[193,39,30,188,194,32],"8159268","darkmighty",[196,39,32,197,60,32],"8159338","other\u002Fneutral\u002Fnone",[199,39,30,188,194,32],"8159243",[201,39,30,188,202,32],"8159578","stephencanon",[96,30,37,204,97,32],"project\u002Fcritical\u002Fperformance",[206,30,32,185,10,37],"8159082",[149,30,30,208,150,32],"project\u002Fneutral\u002Fidea",[210,30,30,185,211,32],"8159182","teisman",[100,30,30,185,101,32],[107,33,37,214,108,32],"project\u002Fcritical\u002Fidea",[216,33,32,217,218,32],"8159148","commenter\u002Fneutral\u002Fidea","robzyb",[220,33,32,221,222,32],"8159152","commenter\u002Fneutral\u002Fnone","sherjilozair",[224,33,32,221,108,32],"8159153",[226,33,32,221,227,32],"8159174","retroencabulato",[229,33,32,217,108,32],"8159179",[231,33,32,217,232,32],"8159201","jacquesm",[234,33,32,217,108,32],"8159235",[236,33,32,221,211,32],"8159167",[238,33,32,221,108,32],"8159190",[240,33,32,221,222,32],"8159580",[242,33,32,221,108,32],"8159597",[153,33,32,217,154,32],[245,33,32,217,108,32],"8160579",[247,33,32,217,218,32],"8205888",[249,33,32,217,250,32],"8160454","Houshalter",[252,33,37,214,191,32],"8159211",[254,33,32,217,108,32],"8159274",[63,33,32,221,64,32],[257,33,32,217,108,32],"8159270",[259,33,30,208,260,32],"8159736","keithpeter",[262,33,30,208,263,32],"8160348","jwmerrill",[265,33,30,208,263,32],"8160368",[267,33,30,208,260,32],"8163235",[269,33,30,208,260,32],"8163228",[271,33,30,208,108,32],"8160565",[273,33,32,217,250,32],"8160461",[275,33,32,217,108,32],"8160479",[277,33,32,217,250,32],"8160822",[59,33,44,279,60,32],"project\u002Fpositive\u002Fidea",[281,44,37,204,250,32],"8160413",[283,284,30,176,285,32],"8159401",6,"killercup",[132,287,30,185,133,32],7,[289,287,32,221,290,32],"8159156","lelandbatey",[292,167,30,293,294,32],"8159097","project\u002Fneutral\u002Fdocs","kken",[296,167,32,174,10,37],"8159101",[298,299,32,197,300,32],"8159255",9,"scott_wilson46",[],[303,308,313,317,321,326],{"id":304,"name":305,"points":306,"category":307},"8173934","Remember Win",455,"productivity",{"id":309,"name":310,"points":311,"category":312},"8158976","Pythonpy",220,"dev_tools",{"id":314,"name":315,"points":316,"category":307},"8173170","92five app",135,{"id":318,"name":319,"points":320,"category":307},"8173179","Opp.io",133,{"id":322,"name":323,"points":324,"category":325},"8175019","Startuplister",101,"web_saas",{"id":327,"name":328,"points":329,"category":307},"8152649","HN-beautify",91,false,"v2",{"id":333,"name":5,"line":5,"ai":330,"cat":19,"year":12,"points":13,"comments":14,"rec":27,"s":334,"top":17,"kw":335,"maker":10,"domain":9,"tier":18,"attempts":32,"strip":336,"url":8,"mix":337,"praise":88,"objection":93,"sub":20},8159010,-0.07,[23,24,25,26],"5035033333133100000000000100333300513330",[30,31,32,33],1794036521173]