cmu-phil / tetrad

Repository for the Tetrad Project, www.phil.cmu.edu/tetrad.
GNU General Public License v2.0
402 stars 110 forks source link

Fix random forward edges random graph generator so that parents don't bunch up at the later nodes. #84

Closed jdramsey closed 8 years ago

jdramsey commented 8 years ago

Also, Greg suggested that we could modify the forward edge method by adjusting the probability of an edge so that the ones later in the order had the same expected number of parents. That wouldn’t be hard to do, and it should solve the too many parents problem.

jdramsey commented 8 years ago

Alternative that think works better: Pick c1, c2 randomly. If c1 == c2 pick another. If c1 > c2 then switch c1 and c2. If c1->c2 is already in the graph, pick another c1, c2. Else add c1->c2.

This method doesn't pick a graph uniformly, but it does eliminate the problem of the nodes at the end of the list getting too many parents.

jdramsey commented 8 years ago

I noticed that the automatic random graph gadget in the GUI was not using the random forward method. Just the menu. Will fix this.

jdramsey commented 8 years ago

Refactored random graph method into GraphUtils and pointed all instances of random graph generation to it, so there is only one copy. Everything behaves well now except for manual graphs, which need some work.

jdramsey commented 8 years ago

Manual always makes an empty graph now, as the interface promises.

jdramsey commented 8 years ago

What's left is to parameterize the interface graph generation method better so that it doesn't rely on Preferences information directly.

ps7z commented 8 years ago

Joe,

Do you know how I incorporate updates in Intellij? When I try to update the project it says:

Can't update: no tracked branch

No tracked branch configured for branch development. To make your branch track a remote branch call, for example, git branch --set-upstream development origin/development

I am not sure what origin/development is. Is that suppose to be https://github.com/cmuphil/tetradhttps://github.com/cmu-phil/tetrad/development?

Peter

From: Joseph Ramsey notifications@github.com<mailto:notifications@github.com> Reply-To: cmu-phil/tetrad reply@reply.github.com<mailto:reply@reply.github.com> Date: Monday, December 7, 2015 at 11:14 AM To: cmu-phil/tetrad tetrad@noreply.github.com<mailto:tetrad@noreply.github.com> Subject: Re: [tetrad] Fix random forward edges random graph generator so that it's uniform. (#84)

What's left is to parameterize the interface graph generation method better so that it doesn't rely on Preferences information directly.

Reply to this email directly or view it on GitHubhttps://github.com/cmu-phil/tetrad/issues/84#issuecomment-162596777.

jdramsey commented 8 years ago

It's not committed to the development branch yet, but when it is (hopefully this afternoon) I'll let you know. Then you just type:

git pull https://github.com/cmu-phil/tetrad development

I think. There's a way to set a tracked repository but I don't know it yet. Sorry, not an expert yet.

Joe

On Mon, Dec 7, 2015 at 1:28 PM, ps7z notifications@github.com wrote:

Joe,

Do you know how I incorporate updates in Intellij? When I try to update the project it says:

Can't update: no tracked branch

No tracked branch configured for branch development. To make your branch track a remote branch call, for example, git branch --set-upstream development origin/development

I am not sure what origin/development is. Is that suppose to be https://github.com/cmuphil/tetrad<https://github.com/cmu-phil/tetrad

/development?

Peter

From: Joseph Ramsey <notifications@github.com<mailto: notifications@github.com>> Reply-To: cmu-phil/tetrad <reply@reply.github.com<mailto: reply@reply.github.com>> Date: Monday, December 7, 2015 at 11:14 AM To: cmu-phil/tetrad <tetrad@noreply.github.com<mailto: tetrad@noreply.github.com>> Subject: Re: [tetrad] Fix random forward edges random graph generator so that it's uniform. (#84)

What's left is to parameterize the interface graph generation method better so that it doesn't rely on Preferences information directly.

Reply to this email directly or view it on GitHub< https://github.com/cmu-phil/tetrad/issues/84#issuecomment-162596777>.

— Reply to this email directly or view it on GitHub https://github.com/cmu-phil/tetrad/issues/84#issuecomment-162615438.

Joseph D. Ramsey Special Faculty and Director of Research Computing Department of Philosophy 135 Baker Hall Carnegie Mellon University Pittsburgh, PA 15213

jsph.ramsey@gmail.com Office: (412) 268-8063 http://www.andrew.cmu.edu/user/jdramsey

jdramsey commented 8 years ago

It's been committed.

Joe

On Mon, Dec 7, 2015 at 1:33 PM, Joseph Ramsey jdramsey@andrew.cmu.edu wrote:

It's not committed to the development branch yet, but when it is (hopefully this afternoon) I'll let you know. Then you just type:

git pull https://github.com/cmu-phil/tetrad development

I think. There's a way to set a tracked repository but I don't know it yet. Sorry, not an expert yet.

Joe

On Mon, Dec 7, 2015 at 1:28 PM, ps7z notifications@github.com wrote:

Joe,

Do you know how I incorporate updates in Intellij? When I try to update the project it says:

Can't update: no tracked branch

No tracked branch configured for branch development. To make your branch track a remote branch call, for example, git branch --set-upstream development origin/development

I am not sure what origin/development is. Is that suppose to be https://github.com/cmuphil/tetrad<https://github.com/cmu-phil/tetrad

/development?

Peter

From: Joseph Ramsey <notifications@github.com<mailto: notifications@github.com>> Reply-To: cmu-phil/tetrad <reply@reply.github.com<mailto: reply@reply.github.com>> Date: Monday, December 7, 2015 at 11:14 AM To: cmu-phil/tetrad <tetrad@noreply.github.com<mailto: tetrad@noreply.github.com>> Subject: Re: [tetrad] Fix random forward edges random graph generator so that it's uniform. (#84)

What's left is to parameterize the interface graph generation method better so that it doesn't rely on Preferences information directly.

Reply to this email directly or view it on GitHub< https://github.com/cmu-phil/tetrad/issues/84#issuecomment-162596777>.

— Reply to this email directly or view it on GitHub https://github.com/cmu-phil/tetrad/issues/84#issuecomment-162615438.

Joseph D. Ramsey Special Faculty and Director of Research Computing Department of Philosophy 135 Baker Hall Carnegie Mellon University Pittsburgh, PA 15213

jsph.ramsey@gmail.com Office: (412) 268-8063 http://www.andrew.cmu.edu/user/jdramsey

Joseph D. Ramsey Special Faculty and Director of Research Computing Department of Philosophy 135 Baker Hall Carnegie Mellon University Pittsburgh, PA 15213

jsph.ramsey@gmail.com Office: (412) 268-8063 http://www.andrew.cmu.edu/user/jdramsey

jdramsey commented 8 years ago

Did some consolidation of the random graph methods. Now GraphUtils in tetrad has the following methods:

public static Graph randomGraph(List<Node> nodes, int numLatentConfounders,
                                int maxNumEdges, int maxDegree,
                                int maxIndegree, int maxOutdegree,
                                boolean connected) {

which calls

public static Graph randomGraphRandomForwardEdges(List<Node> nodes, int numLatentConfounders,
                                                  int numEdges, int maxDegree,
                                                  int maxIndegree, int maxOutdegree, boolean connected) {

which is the new forward edges method. The old forward edges method has been removed. Also there's

public static Graph scaleFreeGraph(int numNodes, int numLatentConfounders,
                                   double alpha, double beta,
                                   double delta_in, double delta_out) {

and

/**
 * Implements the method in Melancon and Dutour, "Random Generation of
 * Directed Graphs," with optional biases added.
 */
public static Graph randomGraphUniform(int numNodes, int numLatentConfounders,
                                int maxNumEdges, int maxDegree,
                                int maxIndegree, int maxOutdegree,
                                boolean connected) {

and that's is. All other shortcut methods have been elimited for clarity. In DataGraphUtils there are some random MIM and bifactor methods that depend on data. The methods for creating graphs in the interface have been moved to tetradapp.util.GraphUtils.

This all seems fair, though comments are welcome. I'll issue a pull request.

jdramsey commented 8 years ago

Hearing no complaints, I'm taking this issue as finished. Closing.