Implement a function named stats_disc_distr in a file called /app/solution.py. This function will calculate statistical values for a discrete probability distribution represented as a list of tuples.
Functionality Requirements
The function should accept a parameter distrib, which is a list of tuples. Each tuple consists of two elements:
The first element (a number) represents the value of a possible outcome (either an integer or a float).
The second element (a float) represents the probability of that outcome (should sum to 1 across all tuples).
The function should perform validation on the distrib input. If the input is invalid, it should return an appropriate error message:
If the probabilities do not sum to 1, return: "It's not a valid distribution".
If any of the first elements in the tuples are not integers or valid floats, return: "All the variable values should be integers".
If both of the above conditions are violated, return: "It's not a valid distribution and furthermore, one or more variable value are not integers".
If the input is valid, calculate the following:
The mean (expected value) of the distribution.
The variance of the distribution.
The standard deviation of the distribution.
Return the calculated values as a list in the following order:
Mean
Variance
Standard Deviation
Input/Output Requirements
Input:
distrib: A list of tuples, where each tuple is of the form (value, probability).
Output:
Either a list [mean, variance, std_dev] if the input is valid or a string with an error message if the input is invalid.
Example
python
# Valid case:
distrib = [(1, 0.5), (2, 0.5)]
result = stats_disc_distr(distrib) # Output: [1.5, 0.25, 0.5]
# Invalid case (incorrect sum of probabilities):
distrib = [(1, 0.6), (2, 0.5)]
result = stats_disc_distr(distrib) # Output: "It's not a valid distribution"
# Invalid case (non-integer values):
distrib = [(1.1, 0.5), (2, 0.5)]
result = stats_disc_distr(distrib) # Output: "All the variable values should be integers"
Implement the function according to the specifications above and ensure it is saved in the correct file path /app/solution.py.