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

Add pairwise #1

Merged
merged 1 commit into from
Mar 15, 2021
Merged

Add pairwise #1

merged 1 commit into from
Mar 15, 2021

Conversation

nalimilan
Copy link
Member

To allow StatsBase to define the generic version (JuliaStats/StatsBase.jl#627) while Distances can continue defining a specific one for its types.

I didn't add real docstrings as the one in StatsBase is relatively complex and it would be absurd to have to update it here if the function evolves.

@@ -1,3 +1,21 @@
module StatsAPI

# pairwise(f, x[, y])
#
# Return a matrix holding the result of applying `f` to all possible pairs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure it will always be a matrix? Maybe it should be a more general n-dimensional pairwise (but admittedly then it should probably be tuple-wise)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular as x and y are allowed to be any iterators what should happen with a 0-dimensional iterator (e.g. when x is a number)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure it will always be a matrix? Maybe it should be a more general n-dimensional pairwise (but admittedly then it should probably be tuple-wise)

"pairwise" seems to imply there are only two elements, right? IIRC we mentioned the possibility of having a more general outer function, but I find pairwise nicer to compute pairwise correlations, and it's already used by Distances.

In particular as x and y are allowed to be any iterators what should happen with a 0-dimensional iterator (e.g. when x is a number)

Well the number of dimensions of the iterator doesn't matter, only the number of elements it contains. So a number gives a 1×1 matrix.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@nalimilan nalimilan merged commit e3e696a into main Mar 15, 2021
@nalimilan nalimilan deleted the nl/pairwise branch March 15, 2021 08:34
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

Successfully merging this pull request may close these issues.

2 participants