Exemple #1
0
        public void GenerateDistribution(string dimension, double threshold, int permutations)
        {
            var edges  = _flatByMod[dimension];
            var tdist  = _tDistByMod[dimension];
            var netcmp = _netCmpByMod[dimension];

            for (var perm = 0; perm < permutations; perm++)
            //Parallel.For(0, permutations, perm =>
            {
                //var randomIndxs = IntArray.From(ShoNS.Stats.Utils.RandPermute(DoubleArray.From(_indexLabels))).ToFlatSystemArray();

                var randomIndxs = new int[58];

                DistroSummary ds = GetGraphDistroSummary(randomIndxs, edges, threshold);

                // Add component size
                netcmp.Add(ds.LargestComponentTopoExtent);

                // Add max Tstat
                if (!Double.IsNaN(ds.MaxEdgeTStat))
                {
                    tdist.Add(ds.MaxEdgeTStat);
                }
            }            //);

            tdist.Sort();
            netcmp.Sort();
        }
Exemple #2
0
        public DistroSummary GetGraphDistroSummary(int[] subjectIdxs, double[,] edges, double threshold, bool includeFullSummary = false)
        {
            //GraphStats gs = new GraphStats();
            DistroSummary ds = new DistroSummary();

            //float[,] arr = new float[4005, 58];
            //for (var i = 0; i < 4005; i++)
            //	for(var j = 0; j < 58; j++)
            //		arr[i, j] = (float)edges[i, j];
            //float[] tstats = new float[4005];

            //Stopwatch sw = new Stopwatch();

            //try
            //{
            //	sw.Start();

            //	square_array(arr, 4005, 58, tstats);

            //	sw.Stop();
            //	long dur = sw.ElapsedMilliseconds;
            //}
            //catch (Exception ex)
            //{
            //	int i = 0;
            //}

            //for (var edgeIdx = 0; edgeIdx < 4005; edgeIdx++)
            //Parallel.For(0, 4005, edgeIdx =>
            //{
            //	var tstat = Math.Abs(TStat(edgeIdx, subjectIdxs, edges));
            //	if (tstat != Double.NaN && tstat > threshold)
            //	{
            //		pair p = _luAdj[edgeIdx];

            //		lock (gs)
            //		{
            //			gs.AddEdge(p.i, p.j);
            //		}
            //	}

            //	ds.MaxEdgeTStat = tstat > ds.MaxEdgeTStat ? tstat : ds.MaxEdgeTStat;
            //});

            //ds.LargestComponentTopoExtent = gs.GetLargestComponentSize();

            //if (includeFullSummary)
            //{
            //	List<int> nodes = gs.GetComponentList();
            //	Dictionary<int, List<int>> cmpNodes = new Dictionary<int, List<int>>();

            //	for (int i = 0; i < nodes.Count; i++)
            //	{
            //		if (cmpNodes.ContainsKey(nodes[i]))
            //		{
            //			cmpNodes[nodes[i]].Add(i);
            //		}
            //		else
            //		{
            //			cmpNodes[nodes[i]] = new List<int>();
            //			cmpNodes[nodes[i]].Add(i);
            //		}
            //	}

            //	ds.Nodes = cmpNodes;
            //}

            return(ds);
        }