Calculate the variance of a distribution analytically I want to calculate the variance of a certain distribution.
I have a rectangle that is getting shifted to the right (i.e. shear transformation). To obtain the distribution I am computing the value of each column. Here is an example of the original data (Left) and its distribution (Right).
This the original data.

and this is its distribution, which was produced by just counting the columns values.

The idea is that I want to compute the variance ($\sigma^{2}$) of each of these distributions from 1 $\rightarrow 10$ and obtain the variance curve, that shows how the variance change with different shear transformations.
The current variance curve of these distribution looks like this:

it is 0 at step 0 because the distribution is flat, then it increases until a certain point before it decreases back again.
What I did so far is use simulated data of a rectangle under a shear transformation and compute the variance of the distribution. Now I would like to come up with an analytical solution (using a formula) to get the variance curve. Therefore I considered the following calculation for the distribution at $2$:

Where $h(x)$ (probability density function) is the following:
$$h(x)\begin{matrix}
ax \cdots \cdots \cdots \cdots  0\lt x\lt x_{1} \\c\cdots \cdots \cdots \cdots x_{1}\lt x\lt x_{2}
 \\-x+w\cdots \cdots \cdots x_{2}\lt x\lt x_{3} \\
0\cdots \cdots \cdots otherwise
\end{matrix}$$
In this case, my continuous random variables is $P(x)$ is uniform $\in [0,x_{3}]$, which is the column values.
Taking all of this into account I compute the variance:
$$var(h(x))=E[h(x^{2})]-E[h(x)]^{2}$$
$$var(h(x))=\int_{0}^{x_{3}}h(x)^{2}P(x)dx-[h(x)P(x)]^{2}dx$$
$$var(h(x))=\int_{0}^{x_{1}}h(x)^{2}P(x)dx+\int_{x_{1}}^{x_{2}}h(x)^{2}P(x)dx+\int_{x_{2}}^{x_{3}}h(x)^{2}P(x)dx - [\int_{0}^{x_{1}}h(x)P(x)dx+\int_{x_{1}}^{x_{2}}h(x)P(x)dx+\int_{x_{2}}^{x_{3}}h(x)P(x)dx]^{2}$$
My question is, how to proceed from the last equation and get the final numeric value of the variance? and can this be translated for the rest of the distributions? if so, how?

Your distribution seems to be a Trapezoidal distribution; analytical expressions for its different modes can be found on the following page: https://en.wikipedia.org/wiki/Trapezoidal_distribution
Hope this helps!
