changeset 33:317bf47b506c

generalise hist
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 22 Nov 2022 19:13:25 +0000
parents 91741bf3ab51
children 2e8002a64f72
files bin/spearman.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bin/spearman.py	Tue Nov 22 11:02:51 2022 +0000
+++ b/bin/spearman.py	Tue Nov 22 19:13:25 2022 +0000
@@ -63,12 +63,20 @@
   plt.grid(True)
   plt.show(block=block)
 
-def hist():
-  sdd=[(i,xm-(i*xsd)) for i in range(-2,3)]
+def hist_x():
+  hist(xm,xsd,[xd[i].mean for i in range(N)],
+       'Mean of rank correlation of each segment x all other segments')
+
+def hist_all():
+  hist(all_m,np.sqrt(all_s.variance),all,
+       'Rank correlation of each segment x whole crawl')
+
+def hist(m,sd,hh,title):
+  sdd=[(i,m-(i*sd)) for i in range(-2,3)]
   fig,hax=plt.subplots() # Thanks to https://stackoverflow.com/a/7769497
   sdax=hax.twiny()
-  hax.hist([xd[i].mean for i in range(N)],color='lightblue')
-  hax.set_title('Mean of rank correlation of each segment x all other segments')
+  hax.hist(hh,color='lightblue')
+  hax.set_title(title)
   for s,v in sdd:
        sdax.plot([v,v],[0,18],'b')
   sdax.set_xlim(hax.get_xlim())