1

How can I compute the Spearman correlation of two m×n arrays in Java? Right now I'm using Apache Commons Math, and all the examples I can find are for calculating the Spearman correlation of two 1×n arrays.

I know how to do it using Excel, but I need to do it in Java.

ruakh
  • 175,680
  • 26
  • 273
  • 307
Nativ Vered
  • 83
  • 1
  • 8

1 Answers1

1

Unless the rows and columns have a special meaning which needs to be preserved, it seems like the easiest way around the problem would be to flatten both arrays into 1x(mn) arrays (making sure to use the same flattening order for both arrays) and then refer to the examples on 1x(-) arrays.

Philip Egger
  • 326
  • 1
  • 11
  • Thank you for your answer. I can use what you suggested in Google sheet, but I cannot use it in Java since I can get only the ro per a single "n" and I need to combine them together. For example I have the columns A ,B and A',B'. I run spearman on A & A' and B&B'. This way I get roA and roB. How do I get one ro using both of them together? @PhilipEdger – Nativ Vered Jan 04 '21 at 15:37
  • @NativVered: Re: "How do I get one ro using both of them together?": Isn't that exactly what this answer suggests? – ruakh Jan 12 '21 at 19:41