''' Social network As you might imagine from the experience of the recent years, modelling an epidemic spread is rather useful. One of the possible models is the so-called "probabilistic network model", in which we model pathogen spread in the group via a network of social contacts. As it turns out, a social network can conveniently be represented by a matrix W. Let's look at an example: W = [ 1 1 0 ] [ 1 1 1 ] [ 0 1 1 ] You can imagine each row and each column representing a person. Our example matrix W therefore outlines a social network of 3 people. When two individuals know each other, the corresponding element in the matrix is 1. In matrix terminology, we can say that element w_ij = 1 when persons i and j know each other. The matrix is also symmetrical, i.e., w_ij = w_ji. If w_ii = 1, then i abides by Socrate's advice: "know thyself". Remember: in w_ij, i denotes the row and j the column. Below we give you a social network matrix W to use in the exercises. We also offer some general tips/hints to keep in mind: - Matrix is symmetric, so (when applicable) make sure not to count the same contact twice. - When looking at contacts between differet individuals, you can exclude elements from matrix diagonal (i.e., the "know thyself" elements). - Remember good coding practices and avoid hardcoding. Your code should work for any social network matrix. ''' import numpy as np # Define social network matrix num_people = 20 # Matrix of 20 people np.random.seed(0) # Setting seed for random number generation for reproducibility W = np.random.choice([0, 1], size=(num_people, num_people), p=[0.6, 0.4]) np.fill_diagonal(W, 1) # Set diagonal elements to 1 ''' Exercise A: Person number 5 How many contacts does person number 5 have? Use Python to find the answer and print it. Hint: How does counting in Python work? ''' # Your code here ''' Exercise B: The influencer Find out which person in your social network has the most contacts (i.e., who's the influencer)? Make a print statement about it. ''' # Your code here ''' Exercise C: Interconnectedness How many social contacts in total are represented in W? Calculate and make a print statement. ''' # Your code here ''' Exercise D: A new friendship Two people have met at a party, so now they also know each other. Make a new social network matrix W_new that also contains this contact. In practice, identify two people in your matrix W that have not known each other (w_ij = 0) and turn the corresponding matrix element(s) to 1. Is the influecer still the same person? You can reuse your code from above to find out. ''' # Your code here