Hi, I'm trying to understand what is computed in graph_tool.correlations. avg_neighbour_corr but I couldn't figured out yet. Take for example the minimal example below: ========= from graph_tool import all as gt import numpy as np g = gt.Graph() g.add_vertex(4) g.add_edge_list([(1,0),(1,2)]) g.vp["weight"] = weights = g.new_vertex_property("double") weights[g.vertex(0)] = 2.7 weights[g.vertex(1)] = 1.3 weights[g.vertex(2)] = 0.3 h = gt.avg_neighbour_corr(g, weights, weights) vlist = gt.find_vertex_range(g, weights, (1,2)) w = [weights[w] for w in vlist[0].out_neighbours()] print np.mean(w), np.std(w) print h[0][1], h[1][1] =========
From the docs I'd expect h[0][1] == np.mean(w) (which is the case) and h[1][1] == np.std(w) (which is not the case).
I'd appreciate any clarification/reference on this subject. In fact, I got to this issue trying to implement the analogous function to graph_tool.correlations.avg_neighbour_corr but looking at *in_neighbours* instead of *out_neighbours* and when I tried to replicate the native function I noticed that the average was almost the same (I think I didn't get yet how is exactly handle the case of having many vertices in the same bin) but the standard deviation was quite different. Regards, -- Santiago Videla http://www.linkedin.com/in/svidela
On 04.06.2015 23:01, Santiago Videla wrote:
From the docs I'd expect h[0][1] == np.mean(w) (which is the case) and h[1][1] == np.std(w) (which is not the case).
As it is written in the documentation, the second value computed is the standard deviation of the _mean_, not the standard deviation of the _population_, which is what you are computing. The standard deviation of the mean is: std(w) / sqrt(len(w))
In fact, I got to this issue trying to implement the analogous function to graph_tool.correlations.avg_neighbour_corr but looking at *in_neighbours* instead of *out_neighbours*
This is trivial, just compute the avg_neighbour_corr with the reversed graph: avg_neighbour_corr(GraphView(g, reversed=True), "in", "out") Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Hi, On Fri, Jun 5, 2015 at 4:31 AM, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 04.06.2015 23:01, Santiago Videla wrote:
From the docs I'd expect h[0][1] == np.mean(w) (which is the case) and h[1][1] == np.std(w) (which is not the case).
As it is written in the documentation, the second value computed is the standard deviation of the _mean_, not the standard deviation of the _population_, which is what you are computing. The standard deviation of the mean is: std(w) / sqrt(len(w))
thanks! I missed that
In fact, I got to this issue trying to implement the analogous function to graph_tool.correlations.avg_neighbour_corr but looking at *in_neighbours* instead of *out_neighbours*
This is trivial, just compute the avg_neighbour_corr with the reversed graph:
avg_neighbour_corr(GraphView(g, reversed=True), "in", "out")
sweet! I'm just starting with graph-tool and I didn't get to know the whole api yet. Regards,
Best, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
-- Santiago Videla http://www.linkedin.com/in/svidela
participants (2)
-
Santiago Videla -
Tiago de Paula Peixoto