open-connectome-classes / StatConn-Spring-2015-Info

introductory material
18 stars 4 forks source link

Algorithms #51

Closed DSP137 closed 9 years ago

DSP137 commented 9 years ago

Which algorithms and types of software are used to do the random sampling of graphs. For example, if I wanted to use a stochastic block model to approximate the connections in a brain (using say 6 categories of the brain, each with their own Bernoulli parameter) how would I use this model in practice? What kind of code would I need to use?

gkiar commented 9 years ago

Can you please elaborate? I'm not sure whether you're asking about software packages which exist, what languages you'd develop your own algorithms in, or what exactly you mean by "how would I use this model". Thanks!

DSP137 commented 9 years ago

I think we've gone over some of the types of software and packages we use. I was more looking for coding tips and where to start, but it may be one of those things where I need to just work in coding to figure out what all the commands are and what they do. Thanks.

imichaelnorris commented 9 years ago

In Python, there's a function in the NumPy called binomial that can produce a random vector or matrix based on a Bernoulli parameter. So, say that I want to create a vector that has a Bernoulli trial. This is my script:

import numpy

p = 0.5 n = 10 x = numpy.random.binomial(1, p, n)

This will give you a vector x of length 10 with the values being either 0 or 1 with a probability of p. You can change n to be a list, so if n = [10, 10], then it will give you a 10 by 10 matrix.

At this point, you can construct as many of these as you want for various regions.

I think the Matlab equivalent of the binomial function in Python is called binornd, if that's more your style.

Does this answer your question?

http://www.mathworks.com/help/stats/binornd.html

See http://pages.uoregon.edu/cfulton/posts/bernoulli_trials_classical.html

DSP137 commented 9 years ago

Thanks!

jovo commented 9 years ago

https://networkx.github.io/ for python http://igraph.org/ for R or python

(we use/develop igraph for R)