In search for a method to approximate a curve into horizontal segments

63 Views Asked by At

In order to model a 24-hour load profile I need to approximate it into smaller number of pieces.

something like this

Is there any method to approximate such a curve?

Would anybody help me to figure out this?

1

There are 1 best solutions below

4
On

Good approximation can be obtained thanks to Fourier series. Examples are shown below.

The data $(x_k\:,y_k)$ is not accurate because it comes from a scanning of the graph published by R. Gholizadeh R. in his question.

$$\text{DATA = }(x_1\:,y_1)\:,\: (x_2\:,y_2)\:,\:...\:,\:(x_k\:,y_k)\:,\:...\:,\:(x_N\:,y_N)$$

$x$ is the time with hour as unit. The period is $24$ hours. Unfortunately the points are missing in the range $0\leq x \leq 1$. This causes a small deviation of the fitted curve. It is supposed that the first point ( at $x=0$ ) has a value of $y$ on the same order than the value $y_N$ of the last point.

The incomplete Fourier series is : $$y(x)\simeq \frac12 a_0+\sum_{n=1}^m a_n \cos\left(\frac{2\pi n}{24}x\right)+\sum_{n=1}^m b_n \sin\left(\frac{2\pi n}{24}x\right)\tag 1$$ The coefficients are computed by numerical integration. $$a_0=\frac{1}{12}\int_0^{24} y(x)dx \simeq \frac{1}{12}\sum_{k=1}^{N-1}\frac{y_k+y_{k+1}}{2}(x_{k+1}-x_k)$$ $$a_n=\frac{1}{12}\int_0^{24} y(x)\cos\left(\frac{\pi n}{12}x\right) dx $$ $$a_n\simeq \frac{1}{12}\sum_{k=1}^{N-1}\frac{y_k\cos\left(\frac{\pi n}{12}x_k\right)+y_{k+1}\cos\left(\frac{\pi n}{12}x_{k+1}\right)}{2}(x_{k+1}-x_k)$$

$$b_n=\frac{1}{12}\int_0^{24} y(x)\sin\left(\frac{\pi n}{12}x\right) dx $$ $$b_n\simeq \frac{1}{12}\sum_{k=1}^{N-1}\frac{y_k\sin\left(\frac{\pi n}{12}x_k\right)+y_{k+1}\sin\left(\frac{\pi n}{12}x_{k+1}\right)}{2}(x_{k+1}-x_k)$$ $N$ is the number of points. $m$ is the number of $\cos$ terms and of $\sin$ terms.

The fitting depends on the choice of number $m$ as shown on the figures below.

The red curve represents the data. The blue curve represents the fitted function : Eq.$(1)$ above.

enter image description here

enter image description here

enter image description here

NOTE :

If we chose too large $m$ the result is worse with oscillations. This is due to the deviations of the numerical integration. Especially the integration on the range $0<x<1$ is bad because the points are missing. If they are more points well distributed on the whole range, the numerical calculus is robust and the deviation can be very small.

The next figure shows the bad result for $m$ too large.

enter image description here