0

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 Answers1

1

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

JJacquelin
  • 66,221
  • 3
  • 37
  • 87
  • Thank you @JJacquelin. Actually, I think I could not convey my issue clearly. The Fourier method gets the step-wise straight lines over a period and gives a function based on sine and cosine terms. However, I need a method which can obtain step-wise straight lines of a given curve points. – rgholizadehr May 12 '19 at 05:49
  • If I well understand you want a piecewise function. But does all linear segments must be horizontal, or not like in the paper https://fr.scribd.com/document/380941024/Regression-par-morceaux-Piecewise-Regression-pdf ? – JJacquelin May 12 '19 at 06:07
  • Yes, exactly I need to change into a piecewise function with horizontal segments. I could not open the link of the paper. – rgholizadehr May 12 '19 at 06:37
  • OK. I checked the link. Apparently the web site "Scribd" is presently in trouble or in maintenance. One have to wait that they fix it. – JJacquelin May 12 '19 at 07:29