Skip to content

Add logarithmic mean function #32

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

Closed
delphidabbler opened this issue Jan 5, 2025 · 2 comments
Closed

Add logarithmic mean function #32

delphidabbler opened this issue Jan 5, 2025 · 2 comments
Assignees
Labels
completed Issue completed and committed to develop. To be closed on next release enhancement New feature or request

Comments

@delphidabbler
Copy link
Owner

delphidabbler commented Jan 5, 2025

The logarithmic mean of two +ve numbers (not same as log-mean), is defined as:

Where x = y:

Mlm(x, y) = x

Where x ≠ y:

Mlm(x, y) = (y - x) / (ln(y) - ln(x))

So:

function LogarithmicMean(const X, Y: Double): Double;
begin
  Assert((X > 0) and (Y > 0));
  if SameValue(X, Y) then
    Result := X
  else
    Result := (Y - X) / (Ln(Y) - Ln(X));
end;

This issue was extracted from issue #16

@delphidabbler delphidabbler self-assigned this Jan 5, 2025
@delphidabbler delphidabbler added documentation Improvements or additions to documentation enhancement New feature or request considering Issue is currently under consideration and removed documentation Improvements or additions to documentation labels Jan 5, 2025
@github-project-automation github-project-automation bot moved this to Considering in Code Snippets Jan 5, 2025
@delphidabbler
Copy link
Owner Author

delphidabbler commented Jan 6, 2025

Version with non-negative Integer parameters:

function LogarithmicMean(const X, Y: Cardinal): Double;
begin
  Assert((X > 0) and (Y > 0));
  if X = Y then
    Result := X
  else
    Result := (Y - X) / (Ln(Y) - Ln(X));
end;

Don't create a version with Integer parameters since both parameters must be > 0 anyway.

@delphidabbler delphidabbler added accepted Issue will be actioned and removed considering Issue is currently under consideration labels Jan 14, 2025
@delphidabbler delphidabbler moved this from Considering to Accepted in Code Snippets Jan 14, 2025
@delphidabbler delphidabbler added the in progress Work has started on this issue label Jan 14, 2025
@delphidabbler delphidabbler moved this from Accepted to In progress in Code Snippets Jan 14, 2025
@delphidabbler
Copy link
Owner Author

Added Double parameter version of LogarithmicMean function, but no overloads.

Implemented by merge commit 28b2b6f

@delphidabbler delphidabbler added completed Issue completed and committed to develop. To be closed on next release and removed accepted Issue will be actioned in progress Work has started on this issue labels Jan 14, 2025
@delphidabbler delphidabbler moved this from In progress to Completed in Code Snippets Jan 14, 2025
@delphidabbler delphidabbler added this to the Next Release milestone Jan 14, 2025
@delphidabbler delphidabbler removed this from the Next Release milestone Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed Issue completed and committed to develop. To be closed on next release enhancement New feature or request
Projects
Status: Completed
Development

No branches or pull requests

1 participant