Deriving a distribution whose pdf has the shape of a square + a triangle (a right trapezoid) I want to the derive the PDF which looks like the sum of a triangular and uniform distribution which looks like this:

To do this I have simply added the PDFs for the rectangular and triangular parts, over the range $[n,N].$
A triangular distribution, with these bounds, has the following PDF:
$$f(x) = \frac{2(N-x)}{(N-n)^2}$$
The scaled uniform distribution has the following PDF:
$$g(x) = \frac{1}{N-n}$$
Then (I believe), the compound distribution is simply:
$$h(x) := f(x) + g(x) = \frac{3N -2x -n}{(N-n)^2}$$
However, I do get a bit confused here, since this distribution needs to be normalised, which is simply done as so:
$$h_{\text{norm}}(x) = \frac{1}{\int_x h(x)} h(x)$$
Does this seem reasonable, or am I wildly off-chart here?
This is a related question but it seems very complicated, for what should be quite simple.
 A: The first step is to find an equation for the unnormalized density function, which in this case is the line at the top of your graph:
$$f(x) \propto 9 - {4(x-n) \over N-n}$$
We then integrate this over the range $[n,N]$ to find the constant of integration $c$:
$$c = \left(9 + {4n \over N-n}\right)\int_n^Ndx \quad - \quad {4 \over N-n}\int_n^Nxdx$$
Working through the integrals gets us to:
$$c = 9N - 9n + 4n -2(N-n)$$
which simplifies to $c=7N-3n$.  Combining this with our unnormalized density function and rearranging terms leads to:
$$f(x) = {9N - 5n -4x \over (7N - 3n)(N-n)}$$
A: Your image shows the sum of two functions which relates to a mixture distribution:
$$h(x) = a g(x) + (1-a) f(x)$$
(see also this discussion)
with


*

*the continuous distribution:
$$g(x) = \begin{cases} \frac{1}{N-n} & \quad \text{ for $ n \leq x\leq$ N } \\
 0 & \quad \text{otherwise}\end{cases}$$

*a triangular distribution:
$$f(x) = \begin{cases} 2 \frac{N-x}{(N-n)^2} & \quad \text{ for $ n \leq x\leq$ N } \\
 0 & \quad \text{otherwise}\end{cases}$$
You do not need to worry about the constant of integration since:
$$\begin{array}{rcl}
\int_n^N h(x)dx &=& \int_n^N \underbrace{( a g(x) + (1-a) f(x))}_{=h(x)} dx \\
& = & \int_n^N  a g(x) dx + \int_n^N (1-a) f(x) dx \\
& = & a \underbrace{\int_n^N  g(x) dx}_{=1} + (1-a) \underbrace{\int_n^N f(x) dx}_{=1} \\
& = & a + (1-a) = 1
\end{array} $$

To get your figure you need to add 5/7 times the uniform (rectangular) distribution and 2/7 times the triangle distribution.

$$h(x) = \frac{5}{7} g(x) + \frac{2}{7} f(x) =  \begin{cases} \frac{\frac{5}{7} + \frac{4}{7} \frac{N-x}{N-n}   }{N-n} & \quad \text{ for $ n \leq x\leq$ N } \\
 0 & \quad \text{otherwise}\end{cases}$$
