Probability Flashcards

(7 cards)

1
Q

In python, using numpy, create a function that outputs n coin flips. Where n is the input of coinflips you want.

A

```Python
def flip_coin(flips:int)->None:
“"”Flips a coin a given number of times and prints the results.
Where 0 represents heads and 1 represents tails.
“””
coin_flips_array = np.random.randint(2, size=flips)
print([“Heads” if f == 0 else “Tails” for f in coin_flips_array])
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the definition of a uniform distribution? Give an example

A

If a situation is uniformly distributed, then, every outcome in that situation is equally likely to happen.

for example, and dice role. If someone said this 6 sided dice role is uniformly distributed, that mean, the probability of rolling a 1,2,3,4,5,6 all have an equal chance of being rolled. In other word, the probability is 1/6.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write a function that takes an input die_sides being the number of faces on the die, that show cases the law of large numbers with graphs. write the description explaining what the law suggest.

A

```python
def law_of_large_numbers(die_sides)->None:
“"”Roll a dice a given number of times and plot it.
The more you roll the closer the frequency of each number(1-6)
will be roughly the same.
“””

number_of_rolls = 1000
for i in range(1, 4):
    
    # +1 because the upper bound is exclusive not inclusive
    rolls_1000 = np.random.randint(1, die_sides+1, size=number_of_rolls)
    plt.figure(figsize=(8, 5))
    plt.hist(rolls_1000, bins=np.arange(1, die_sides+2),align='left',rwidth=0.8,color='skyblue')
    plt.title(f'Rolling a {die_sides}-sided die 1000 times')
    plt.xlabel('Die Face')
    plt.ylabel('Frequency')
    plt.show()
    ##### Increasing the number of rolls by a factor of 10 each time
    number_of_rolls *= 10 ~~~
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define an experiment with respect to probability. Give an example

A

experiment is any procedure or process that can be repeated infinitely (in theory) and has a well-defined set of possible results.
An example is flipping a coin, rolling a die, measuring a patient’s temperature, or recording the time it takes for a website to load. all can be repeated and has a set of possible results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the possible result of a experiment called, and can you give me examples related to the following:

1.flipping a coin
2. rolling a die
3. measuring a patient’s temperature
4. recording the time it takes for a website to load

A

The result of an experiment is called an OUTCOME.

For flipping a coin, the outcomes are Heads (H) or Tails (T).

For rolling a standard six-sided die, the outcomes are the integers 1, 2, 3, 4, 5, 6.

For measuring temperature, an outcome could be 37.2°C.

For website load time, an outcome could be 1.34 seconds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is sample space?

A

often denoted by
S or Ω (Omega), is the set of all possible outcomes of an experiment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly