0

https://towardsdatascience.com/cyclical-features-encoding-its-about-time-ce23581845ca encodes a timestamp in terms of sin(x), cos(x). First, they map X's "hour of day" and "day of year" to the range [0, 2*PI]. Finally, they feed the value into sin() and cos().

Given sin(x) = y and cos(x) = z, how do I get back the original "hour of day" and "day of year"?

Gili
  • 86,244
  • 97
  • 390
  • 689
  • Each `{y,z}` pair is mapped from an indeterminate and potentially infinite number of `x` values. So it is not generally possible to recover the original `x`. At best you can get back a *principal value*. – njuffa Dec 13 '21 at 21:57
  • @njuffa I've clarified the question. `x` does not have an infinite range. It must lie within `[0, 2*PI]`. If we can reverse `sin/cos` back to the input `[0, 2*PI]` I can then map back to the time of day, and day of year associated with `x`. – Gili Dec 13 '21 at 22:34
  • 1
    In that case, use `atan2`. – njuffa Dec 13 '21 at 22:36
  • @njuffa That did it. Thank you! If you post a more elaborate answer, I'll mark it as accepted. – Gili Dec 13 '21 at 22:55
  • This question seems to be duplicate of [this other question](https://stackoverflow.com/questions/14079127/getting-angle-back-from-a-sin-cos-conversion) – njuffa Dec 13 '21 at 23:09
  • @njuffa Agreed. I'll flag it as a duplicate. Thanks again. – Gili Dec 14 '21 at 06:07

0 Answers0