Simple closed-form solution for alpha in detect_clearsky #2171
agodbehere
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Thanks for pointing this out. The implementation went through several iterations and this slipped by. Could you check that formula for the minimum? I get \sum GC / \sum C^2 |
Beta Was this translation helpful? Give feedback.
2 replies
-
I would be happy to do so. Thank you!
…On Wed, Aug 21, 2024 at 09:49 Cliff Hansen ***@***.***> wrote:
I had forgotten about that typo in the 1996 paper. The intent is to scale
the clear-sky model by \alpha, not to scale the GHI measurements.
Are you interested to submit a pull request to replace the call to
scipy.optimize?
—
Reply to this email directly, view it on GitHub
<#2171 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANUIXR5H2XOPWNNTIZGYELZSSLE3AVCNFSM6AAAAABM2QO4ZSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANBQHAYDAMI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The algorithm in clearsky.detect_clearsky optimizes for a scaling parameter alpha by finding a value that minimizes the root mean-squared error (RMSE) between measurements and a scaled clear-sky model. Currently, the implementation computes the RMSE and uses scipy.optimize to iteratively minimize the function. However, a simple closed-form solution exists, bypassing the need to call scipy.optimize.
The objective function is$f(\alpha) = \sqrt{\frac{\sum_i (G_i - \alpha C_i)^2}{n}}$ , where $G$ represents measurements of GHI and $C$ represents the clear-sky model.
Since$f(\alpha)$ is nonnegative, $\arg\min_\alpha f(\alpha) = \arg\min_\alpha f^2(\alpha)$ . The value $n$ is a constant and similarly does not affect the solution.
Thus, we end up with a modified objective function$\hat{f}(\alpha) = \sum_i (G_i-\alpha C_i)^2$ . Solving for $\frac{d\hat{f}}{d\alpha} = 0$ yields the optimal value: $\hat{\alpha} = \frac{\sum_i G_i^2}{\sum_i G_iC_i}$ . The result is nonnegative, so the constraint $\alpha > 0$ is satisfied implicitly.
Beta Was this translation helpful? Give feedback.
All reactions