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 #2172

Closed
agodbehere opened this issue Aug 21, 2024 Discussed in #2171 · 2 comments
Closed

Simple closed-form solution for alpha in detect_clearsky #2172

agodbehere opened this issue Aug 21, 2024 Discussed in #2171 · 2 comments

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.

@yhkee0404
Copy link
Contributor

Duplicate of #2216

@cwhanse
Copy link
Member

cwhanse commented Sep 28, 2024

Closed via #2217

@cwhanse cwhanse closed this as completed Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants