Hi, welcome to this new video. In this video, we're going to start learning about probability. This is going to be a very, very simple introduction to probability. This is not again a probability course, but within design, it's useful to have certain understanding of how we could actually use probability for determining variation. What do we mean by probability? Probability is a mathematical concept that helps us quantify the likelihood of certain events. When we start using the idea of a distribution or a probability distribution, we start thinking of a statistical function that describes all the possible values and likelihoods of those values to happen within a given range. What do we mean by all the possible outcomes, i you start thinking of, let's say all the possible circles, as you can see in the drawing on the right, maybe we have a total number of nine circles and maybe the number of desired outcomes is two. We can start thinking, what is the probability of having two items maybe fitting up certain criteria? Perhaps we would perform a different code for those items. It's important to know that we are evaluating in relation to the totality of the possible outcomes. A simple way of thinking of probability is through percentages, and we could start by creating a random number. We know the function random, and if we start thinking of a random value 0-1 obviously considering decimal places, we can quickly make a bit of math to understand the percentage, if we would say something that is less than 0.75 that means that there's going to be a roughly 75% chance of an event to occur. If we actually say bigger than 0.75 in such condition, we would have a 25% of that happening. This is not going to be exact because when we're using a random value, the random value will be different every time. You're not having exactly the 75, 25, there is going to be a small variants there. But especially when we're thinking of large populations, let's say we have hundreds of elements in the screen, we can rely that we can operate with a sense of probability. Let's say we want to color some of those items, like 25% of those items, differently than the rest. This is where probability can actually play out very nicely. Let's look at an example code. Here we go. We have our template. Let's start by creating a loop, like a four loop. Because I would like to work with a range of elements. Four range, 0-100. A little bit of a different language there. What we're going to do is create an ellipse, a circle, basically in a random location in the screen, so let's say x. If we want to use, let's always remember to import the random module up here. Let's do that uniform. Uniform here, because I want all the decimal places. If I want to distribute the ellipses, I'm going to draw ellipses basically everywhere in the Canvas. I'm going to do a random value between zero and the size of the screen. The x, it's going to be between zero and the size of the screen. We can copy this line for the y variable. We're going to create two variables on x and y, and let's use the height of the screen, in this case here. Now we can actually draw our ellipse. Ellipse x, y, and the size, it doesn't matter. We can do 20, 20. At this point, we should have 100 ellipses in the screen. Let's just make sure that we're going to do feel white at the moment and maybe no stroke. Let's see if we're not having any errors. We have 100 of those. That's all good. Let's imagine that we want to use this notion of randomness and probability to color red or change the color of the ellipses to 25% or 20% of them, a particular percentage. The first thing we're going to do is create a random value. Random number. This is going to be a variable. We can here use random.uniform between zero and one. If we print this value, let's just print it first to see what we're getting. Every time you're using random, maybe you're not so sure yet about the different versions of random that are out there, you can certainly go and read the documentation. But you see that we're getting a different decimal place value. It's unlikely that we're going to get one exactly or zero exactly, but because we have so many decimal values. But we have a distribution of values. Now we can comment out this print statement. For each one of those 100 ellipses, we have a random value assigned to each one of them. Let's do an if statement. Remember that every time we're looping through one version of the loop, we're creating a new random value and we're going to be evaluating it differently. So if this random value is bigger than 0.2, so let's give 80% chance of the first event to occur. We're going to add here some code. Then let's say else and here we can do some other code. What kind of code do we want? I think that for now I'm going to obviously leave that door open for you to explore graphically something more interesting. Just let's change the field. Let's say if it's bigger than 0.2 meaning that 80% of the ellipses are going to be white and maybe 20% of them are going to be red. Let's look at that. As you can see, if you count, maybe sometimes you'll see 21 or 19, or 18. The random doesn't really give us an exact distribution, but roughly speaking, we should be having 20% of our ellipsis being in the second color. I think this is the beauty of working, especially in design, working with probability, you're designing probabilistically. You're not exactly saying where the red spheres are, or the total number of them. But you're roughly having a composition between an 80% of white spheres and a 20% of red ones. There's a lot of interesting ideas that come from thinking, probabilistically in design. If you want this distribution to be more equal, like 50% like a 50/50, you can actually put a 0.5 here. There you go. You should have a balance number. If you actually bring this value up, right, somewhere to maybe 500, because we're generating a random value every time, we are not depending on this value. This number could be any number: it could be 1,000, it could be 300. We're always going to get a 50/50% distribution in this case because we are actually evaluating a value between zero and one, and we're cutting it halfway. We're going to be using this technique quite a bit in the future, but again, this is the introduction to this concept. Here we have again 20% and again I invite you to play by increasing this number to a much larger. Again, the point is not to count and see if this is right or wrong. But it's roughly having a sense, am I getting a 20%? It might so happen that you're actually having some spheres on top of each other, so it might be very difficult to evaluate precisely. You could create a counter to see how many variable that counts. If this condition is true, I'm counting plus one. If second condition is true, you count plus one in the other one, and you would see if in fact what is the final count after you on the loop. But again, that could be a little bit of an extra assignment that you can try on your own. We're going to leave this video here and I'll see you in the next one. We're going to continue looking at different functions for design.