Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac96201

Browse files
authored
Merge branch 'HackYourFuture:main' into main
2 parents 7c4dcfc + d206ed0 commit ac96201

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Week2/MAKEME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Practice, practice, practice. Same as week 1, you are not handing in any homework, but are going to practice as much javascript as you can. Play around with the exercises mentioned below, remember that you can copy the code into [jsTutor](http://pythontutor.com/javascript.html#mode=edit) to step through the code, or look at it in the debugger in the browser/vscode.
44

5-
## **Todo list **
5+
## **Todo list**
66

77
1. Practice the concepts
88
2. Prep exercises

Week3/prep-exercises/2-experiments/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Let's do some experiments! One thing computers are great at is doing the same thing over and over and over again, so let's use that to see how random the random function in JavaScript is. In the `index.js` there is an explanation of what to implement. In essence we want to simulate the rolling of a die a lot of times and then track how many times a certain value was rolled.
44

5+
For a fair die the chance of rolling a certain value should be equal for all possible values. When rolling a six-sided die many times we therefore expect the number of times each value is thrown to approach 16.6% (1/6) of the total number of rolls. The more rolls we do the closer we should get to the expected value, following the [Law of large numbers](https://en.wikipedia.org/wiki/Law_of_large_numbers).
6+
7+
> Wikipedia: _In probability theory, the law of large numbers (LLN) is a theorem that describes the result of performing the same experiment a large number of times. According to the law, the average of the results obtained from a large number of trials should be close to the expected value and tends to become closer to the expected value as more trials are performed._
8+
9+
In this prep exercise we are using the `Math.random()` function to simulate throwing a die. So what we are actually testing here is how well `Math.random()` distributes its values evenly across the range of 0 to 1 when called many times. We will do this for an increasing number of rolls (`sampleSize` in the code) and expect the results to even out to 16.6% across all values.
10+
511
## Things to think about
612

713
- The `valueCounts` is implemented as an array. Do you think there is another way to store this? Why do you think the decision was made to go with an array?

0 commit comments

Comments
 (0)