I can't understand this cumulative distribution function. I would like to calculate the data distribution function:

F(t) := P(X <= t) ~ sum_i freq(observation_i <= t)/total_observation =: f(t)

Having the datas:

List_Goal: [1, 2, 2, 1, 2]

Each of these values (1, 2, 2, 1, 2) is a goal scored by a club in previous matches. For example, the Liverpool club: in the first match he scored 1 goal, in the second match he scored 2 goals, in the third match he scored 2 goals, in the fourth match he scored 1 goal, in the fifth match he scored 2 goals. In all the club played 5 matches. So in the sixth match, still to be played, we want to know the Cumulative distribution function in relation to the goals of the 5 previous matches.

How many 0 goals are scored? 0/5
How many 1 goals are scored? 2/5
How many 2 goals are scored? 5/5


0 goals 0/5 = 0 
1 goals 2/5 = 0.4
2 goals 5/5 = 1

REQUEST: If it were correct, then how should we proceed next?

Thank you all!!!

  • 1
    $\begingroup$ Before I answer your question I would like to ask you explain in your own words what is a cumulative distribution function. $\endgroup$
    – Math-fun
    Commented Oct 24, 2023 at 6:49
  • 1
    $\begingroup$ @Math-fun Premise that i'm just a math enthusiast and i'm not even good at it. Maybe I can be wrong, but the cumulative distribution function is a function F(x) that takes values over the set of real numbers, enclosing various data before or after a given point. It depends on a real variable and a probability distribution variable that returns the probability that the variable is equal to or less than a specific value. I don't know if I said it right. Can you help me please? $\endgroup$ Commented Oct 24, 2023 at 7:01
  • $\begingroup$ Sounds good :-) So let the random variable you are looking at be $X$. Which values can $X$ take in your question? $\endgroup$
    – Math-fun
    Commented Oct 24, 2023 at 7:03
  • $\begingroup$ @Math-fun I don't know, that's why I was asking for help on the sheet I attached to the question. In theory, even if not very well, I know what the cumulative distribution function is. But I can't understand the exercise. For this reason I asked for help. In the exercise we use the basic List_Goal values: [1, 2, 2, 1, 2]. Then I don't understand. Can you help me please? Thank you $\endgroup$ Commented Oct 24, 2023 at 7:18
  • $\begingroup$ Sure, this is what I try: I am trying to communicate to you what you should understand first before moving to find the CDF. As you mentioned in your explanation, CDF helps us understand the behavior of a random variable. But before we move to see what the CDF of a random variable is, we need to understand the variable we wish to analyze. And the first thing to do here is to know which value does the random variable take. $\endgroup$
    – Math-fun
    Commented Oct 24, 2023 at 7:25

3 Answers 3


given the comments, I think it make sense that I summarize our discussions here.

First, a random variable is a "mathematical model" which we use to model real world phenomon. In your example the random variable can be defined as follows:

$X=$ the number of goals scored.

And $X$ is indeed a function of certain events that should take place so that a certain number of goals are socred. Now let's move on to the values that this random variable (which is a function of events) takes. Obviously $X$ can't be negative and obviusly it can only take integra values, $0$ (no goal), 1 (one goal), 2 (two goals), and so on. But $X$ cannot be a very large number in this case. So using these arguments we may refine our model for the number of goals:

$X=$ the number of goals scored, where $X\in\{0,1,2,...,g_m\}$ where $g_m$ is the maximum number of goals possible to be scored.

So far so good. We now may take one step further and ask ourselves what is the probability that we have no goals scored? And here we need a tool that helps us quantify the probability that $X=0$. This tool is called a probability measure, since it measures the probabilities. Accordingly we can go on and ask ourselves what is the probability that $X=x$ where $x\in\{0,1,2,...,g_m\}$. And we take one step further and write $$\Pr(X=x)=p_x.$$ That is, $p_0$ is the probability that we score 0 goals, $p_1$ is the probability that we score 1 goals and so on.

Obviously this was just abstract and had nothing to do with "reality". To make our model usable, we need to observe how many goals are scored over time and using these observations we could find "some guesses" about $p_x$. For example in your small set set of observatiobs we have 3 games with 2 goals. Therefore using your observations we may guess (read estimate) the $p_2$ as $\frac35$ (since 3 times out of 5 times we have scored 2 goals), which is essentially the fraction of games with 2 goals, we write $$\widehat{p}_2=\frac35,$$ where $\widehat{}$ is there to remind us that "hey you have a guess of $p_2$, you don't have $p_2$". Now can you "estimate" $p_x$ for $x=0$, $x=1$ and other values of $X$ from your observations (which we call it a sample)?

once you identify the estimated probabilities, you may go on step further and estimate the CDF too. Share how you proceed, if you wish of course!

  • $\begingroup$ Some things I understood, other things I didn't understand. Your answer is great, but very theoretical and not very practical. Could you update something to your answer please? Could you add the steps (without explanation) to get to the final result? For example: 1 step, 2 step, 3 step, etc? Thank you $\endgroup$ Commented Oct 24, 2023 at 8:28
  • $\begingroup$ The point for me here is not to write all the answer for you, but to help you understand the question and find the answer yourself. I will of course provide you with further explanations once I know which steps you don't understand and what the problem you are facing :-) I understand that you wish to understand things and you are not necessarily after the "fina result". correct me, please, if I am wrong :-) $\endgroup$
    – Math-fun
    Commented Oct 24, 2023 at 8:47
  • $\begingroup$ In my example (and the one on the attached sheet): 0 goals were scored 0 out of 5 times; 1 goal was scored 2 times out of 5; 2 goals were scored 3 times out of 5; So according to your reasoning, i will have p0= 0/5, p1=2/5, p2=3/5. If so, then why is there 0/5, 2/5 on the paper, but no 3/5? On the sheet I read 5/5, but I didn't understand why 5/5. After your explanation, therefore after having calculated p0= 0/5, p1=2/5, p2=3/5, how should I proceed? $\endgroup$ Commented Oct 24, 2023 at 8:59
  • $\begingroup$ Great! Can you estimate the cdf of $X$ using your observations (I am not talking about the handwritten page you have attached) at 0, 1, 2? $\endgroup$
    – Math-fun
    Commented Oct 24, 2023 at 9:03
  • $\begingroup$ Can you show me the results of the X cdfs? (just to understand if I calculate them correctly) Furthermore, after having calculated them, how should I proceed? $\endgroup$ Commented Oct 24, 2023 at 9:12

I am not 100% sure I understand your question. Please let me know if this is what you are looking for:

To find the empirical cumulative distribution function for integer data you need to:

  1. Calculate the proportion of each possible observation;
  2. Order these proportions using the increasing ordering of the corresponding integer values;
  3. Calculate the cumulative sum of these proportions.

Below is an example with R for your data:

# The integer values
x <- c(1, 2, 2, 1, 2)
# The function "table" will already order the values
# according to the order of the integers
# Validate with the "ecdf" function, which creates
# a function to calculate the empirical CDF
  • $\begingroup$ I don't know, I don't know if this is what I'm looking for. I would like to receive the same thing that is written on the paper. I guess you know more than me. Why aren't you 100% sure? Is the result of what you wrote the same as the result of the article? P.S: could you also write it in Python? $\endgroup$ Commented Oct 24, 2023 at 3:48

I had already found the answer on my own, but I didn't realize it. It seems right to share it anyway. I thought we needed to proceed differently and write other things. However, I thank everyone for their attention. I voted on everyone's answers

The user Math-fun came close to what I was looking for and was kind in his explanation, but his answer wasn't what I was looking for. To solve the exercise I didn't have to count the number of goals and obtain for example p2 = 3/5 (as in the user's answer), but I had to count how many observations are less than or equal to 0, 1, and 2? So for example I didn't need p2= 3/5, but p2= 5/5

The solution to the exercise is this:

If the goals scored are <= 0, then i will have goals 0/5 = 0
If the goals scored are <= 1, then i will have goals 2/5 = 0.4
If the goals scored are <= 2, then i will have goals 5/5 = 1

I know:

Observation <= 0 (0) goals: CDF calculation
Observation <= 1 (0.4) goals: CDF calculation
Observation <= 2 (1) goals: CDF calculation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.