Skip to content

Add Monte Carlo Integration in Emojicode. #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 54 additions & 0 deletions contents/monte_carlo_integration/code/emojicode/monte_carlo.emojic
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
🐇 ☝️ 🍇
🖍🆕 x 💯
🖍🆕 y 💯

🆕 🍼 x 💯 🍼 y 💯 🍇 🍉

❗️ 📪 ➡️ 💯 🍇
↩️ x
🍉

❗️ 📫 ➡️ 💯 🍇
↩️ y
🍉
🍉

🐇 🌕 🍇
🖍🆕 radius 💯

🆕 given_radius 💯 🍇
🏧 given_radius❗️ ➡️ 🖍radius
🍉

❗️ 📥 point ☝️ ➡️ 👌 🍇
📪 point❗️ ➡️ point_x
📫 point❗️ ➡️ point_y
↩️ 🤜point_x ✖️ point_x ➕ point_y ✖️ point_y🤛 ◀️ 🤜radius ✖️ radius🤛
🍉
🍉

🐇 🤡 🍇
🐇 ❗️ 🏃‍♀️ samples 🔢 ➡️ 💯 🍇
🆕🌕🆕 1.0 ❗️ ➡️ circle
0 ➡️ 🖍🆕 count

🆕🎰🆕 ❗️ ➡️ random

🔂 i 🆕⏩⏩ 0 samples❗️ 🍇
🆕☝️🆕 💯 random❗️ 💯 random❗️❗️ ➡️ point
↪️ 📥 circle point❗️ 🍇
count ⬅️ ➕ 1
🍉
🍉

↩️ 4.0 ✖️ 💯 count❗️ ➗ 💯samples❗️
🍉
🍉

🏁 🍇
😀 🔤Running with 10,000,000 samples.🔤❗️
🏃‍♀️🐇🤡 10000000❗️ ➡️ pi_estimate
😀 🍪🔤The estimate of pi is: 🔤 🔡 pi_estimate 10❗🍪❗️
🏧 🤜pi_estimate ➖ 🥧🕊💯 ❗️🤛❗️ ➗ 🥧🕊💯 ❗️ ✖️ 100 ➡️ percent_error
😀 🍪🔤The percent error is: 🔤 🔡 percent_error 10❗ 🔤%🔤🍪❗️
🍉
4 changes: 4 additions & 0 deletions contents/monte_carlo_integration/monte_carlo_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ each point is tested to see whether it's in the circle or not:
[import:1-4, lang:"ruby"](code/ruby/monte_carlo.rb)
{% sample lang="f90" %}
[import:1-8, lang:"fortran"](code/fortran/monte_carlo.f90)
{% sample lang="emojic" %}
[import:23-27, lang:"emojicode"](code/emojicode/monte_carlo.emojic)
{% sample lang="php" %}
[import:4-7, lang:"php"](code/php/monte_carlo.php)
{% sample lang="lua" %}
Expand Down Expand Up @@ -149,6 +151,8 @@ Feel free to submit your version via pull request, and thanks for reading!
[import, lang:"ruby"](code/ruby/monte_carlo.rb)
{% sample lang="f90" %}
[import, lang:"fortran"](code/fortran/monte_carlo.f90)
{% sample lang="emojic" %}
[import, lang:"emojicode"](code/emojicode/monte_carlo.emojic)
{% sample lang="php" %}
[import, lang:"php"](code/php/monte_carlo.php)
{% sample lang="lua" %}
Expand Down