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

Rolling argmax and argmin functions #2

Open
testforvln opened this issue Aug 13, 2022 · 10 comments
Open

Rolling argmax and argmin functions #2

testforvln opened this issue Aug 13, 2022 · 10 comments

Comments

@testforvln
Copy link

Could you add rolling argmax and argmin functions? Just to return the position of the max/min value.

@AdilZouitine
Copy link
Member

Hello,
Yes, it is possible, but I don't see the point of having a rolling argmin?
Do you have an example? 😄

@testforvln
Copy link
Author

Yeah, when calculating some factors in quant finance, the rolling argmin/argmax functions are very useful.

@AdilZouitine
Copy link
Member

AdilZouitine commented Aug 31, 2022

I understand the interest!
Do you want to make the pull request? If not, I can do it next weekend after my holidays 😄

I will also move the repository to https://github.com/online-ml and probably rename the library.

@testforvln
Copy link
Author

Sorry that I failed to implement argmin/argmax functions by myself. It would be very nice of you to implement these functions anytime you like.

@AdilZouitine
Copy link
Member

AdilZouitine commented Sep 1, 2022

No problem 😄 I'll do it!

I'll ping you when it's done.

@testforvln
Copy link
Author

Hi, do you have any progress on this issue? I'm wondering if the argmin/argmax function could only be implemented by binary search the item each time on updating.

@AdilZouitine
Copy link
Member

Hey, I'm on vacation; I add this issue to my todo list 😄

@testforvln
Copy link
Author

Sorry to bother you. Have a good time!

@AdilZouitine
Copy link
Member

Hi @testforvln,
I implemented the rolling argmin; the code is here: https://github.com/online-ml/watermill.rs/blob/rolling_argmin/src/argmin.rs
I made some caching to avoid searching the argmin at each update.

@testforvln
Copy link
Author

That's great! I thought of maintaining another sorted order number for sorted_window, but every update would cost O(n) for maintaining the sequence. Your solution of caching is very suitable for this argmin function.

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

2 participants