Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple closed-form solution for alpha in detect_clearsky - clarified #2216

Closed
agodbehere opened this issue Sep 19, 2024 Discussed in #2171 · 0 comments · Fixed by #2217
Closed

Simple closed-form solution for alpha in detect_clearsky - clarified #2216

agodbehere opened this issue Sep 19, 2024 Discussed in #2171 · 0 comments · Fixed by #2217
Milestone

Comments

@agodbehere
Copy link
Contributor

Discussed in #2171

Originally posted by agodbehere August 20, 2024
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_iC_i}{\sum_i C_i^2}$. The result is nonnegative, so the constraint $\alpha > 0$ is satisfied implicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants