CPU Performance Please, help me to understand the mathematics behind the following formula of CPI. Why do we calculate CPI the way it's done on the pic? The formula reminds me the expected value from stochastic, but do we have a random value here? 


I will explain with a simple example.
Suppose that you have $100$ random operations, then on average:


*

*$35$ of them are ALU    operations, each one taking 1 clock cycle

*$25$ of them are Load   operations, each one taking 2 clock cycles

*$15$ of them are Store  operations, each one taking 2 clock cycles

*$25$ of them are Branch operations, each one taking 3 clock cycles


The average number of clock cycles per operation is therefore:
$$\frac{35\cdot1+25\cdot2+15\cdot2+25\cdot3}{100}$$
Which is equivalent to the formula given in your question:
$$0.35\cdot1+0.25\cdot2+0.15\cdot2+0.25\cdot3$$
