#๐Ÿ”’ monte carlo simulation

19 messages ยท Page 1 of 1 (latest)

cobalt cradleBOT
#

@primal notch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

wise stone
#

what's the issue?

thin wraith
#

what is the code, and what issue you're having? please don't say that we should provide all of them without you trying. if yes, then at least try solving the question.

#

we can give you a few hints tho.

#

ok i gotta go to sleep im sorry

stoic crow
primal notch
primal notch
neon wigeon
#

What is the first, and what is the second?

primal notch
neon wigeon
#

Sorry, i only see one task

#

To print the probability given the described setup

primal notch
#

A table has a chessboard integrated into the centre of the table. A round coin fits exactly inside of a square on a chessboard. The coin is dropped to land flat on the table, with at least a part of the coin on the chessboard. Using Monte Carlo simulation, what is the probability that the coin covers the corner of four chessboard squares?

#chess board = 8x8
#board across the chess board = 0.5 away from the edge
#circle radius = 0.5 (half of edge of sqaure)
import random as ra
area_of_circle = (22/7)0.50.5

Area_of_possible_area = (99)-(11)+((22/7)0.50.5)
count = 0
n_trails = 100000

for i in range(n_trails):
x = ra.uniform(0,Area_of_possible_area)

if x >= 0 and x<= (49*area_of_circle):
count+=1
else:
pass

probability = count/n_trails

print(probability)

neon wigeon
#

!code

cobalt cradleBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

wise stone
#

the purpose of a monte carlo simulation is to complete a set of actions step by step many times (e.g. millions) and then use the outcome of each set of actions to determine the probability of something happening. In Liam's case, he has 16 squares, let's say 8 white, 8 black. One by one, populate a 4x4 grid with either a black or a white square and once the board is complete, compare it against a valid checkerboard to see if your combination is valid. Repeat many times and count how many valid vs invalid boards there are and their ratio is the probability you're after

cobalt cradleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ monte carlo simulation