User Tools

Site Tools


tanszek:oktatas:techcomm:statistical_properties

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tanszek:oktatas:techcomm:statistical_properties [2024/10/01 06:06] – [Frequency of Events] kneheztanszek:oktatas:techcomm:statistical_properties [2024/10/04 19:17] (current) knehez
Line 57: Line 57:
 So we can say that (according to this formula) the total probability for both events is 4/6. So we can say that (according to this formula) the total probability for both events is 4/6.
  
-**Example 3**: What is the probability that we roll the dice twice and the results will be 6 in both cases?+**Example 2**: What is the probability that we roll the dice twice and the results will be 6 in both cases?
  
 The probability of throwing a 6 is 1/6, but we cannot multiply it by 2 and take the result (2/6). We can not do that because both events are independent. There is no connection between the 2 trials, so we have to look at them as independent events. So the result will be the multiplication of both events: The probability of throwing a 6 is 1/6, but we cannot multiply it by 2 and take the result (2/6). We can not do that because both events are independent. There is no connection between the 2 trials, so we have to look at them as independent events. So the result will be the multiplication of both events:
Line 63: Line 63:
 $$ p(A) \times p(B) = \frac{1}{6} \times \frac{1}{6} = \frac{1}{36} $$ $$ p(A) \times p(B) = \frac{1}{6} \times \frac{1}{6} = \frac{1}{36} $$
  
-**Example 2**: What is the probability of getting at least one 5 when rolling two dice?+**Example 3**: What is the probability of getting at least one 5 when rolling two dice?
  
 Let //Event A// represent rolling a 5 on the first die and //Event B// represent rolling a 5 on the second die. These are independent events. Let //Event A// represent rolling a 5 on the first die and //Event B// represent rolling a 5 on the second die. These are independent events.
Line 76: Line 76:
  
 **Example 4:**:  Woman is expecting twins, what is the probability that one of the children will be a girl? **Example 4:**:  Woman is expecting twins, what is the probability that one of the children will be a girl?
 +
 +Create sets containing all the possibilities.   
 +
 +Try the following c code here: https://www.onlinegdb.com/online_c_compiler and examine the results.
 +
 +<sxh c>
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <time.h>
 +
 +#define SIMULATIONS 1000
 +
 +// Function to simulate the birth of twins
 +int simulate_twins() {
 +    // Randomly determine the gender of the twins (0 = boy, 1 = girl)
 +    int first_child = rand() % 2;
 +    int second_child = rand() % 2;
 +
 +    // Return 1 if there is at least one girl, otherwise 0
 +    return (first_child == 1 || second_child == 1);
 +}
 +
 +int main() {
 +    int at_least_one_girl = 0;
 +
 +    // Initialize the random number generator
 +    srand(time(0));
 +
 +    // Simulate 1000 pairs of twins
 +    for (int i = 0; i < SIMULATIONS; i++) {
 +        if (simulate_twins()) {
 +            at_least_one_girl++;
 +        }
 +    }
 +
 +    // Calculate and print the result
 +    double probability = (double)at_least_one_girl / SIMULATIONS * 100;
 +    printf("In %.2f%% of cases, there is at least one girl in the twin pair.\n", probability);
 +
 +    return 0;
 +}
 +</sxh>
 +
  
 **Example 5:**: https://en.wikipedia.org/wiki/Monty_Hall_problem **Example 5:**: https://en.wikipedia.org/wiki/Monty_Hall_problem
  
tanszek/oktatas/techcomm/statistical_properties.1727762771.txt.gz · Last modified: 2024/10/01 06:06 by knehez