public virtual FacetCountStatistics GenerateStatistic(int[] distribution, int n) { int[] tmp = distribution; int totalSampleCount = distribution.Length; bool sorted = false; if (n > 0) { totalSampleCount = Math.Min(n, tmp.Length); // this is crappy, to be made better with a pq int[] tmp2 = new int[distribution.Length]; System.Array.Copy(distribution, 0, tmp2, 0, distribution.Length); System.Array.Sort(tmp2); tmp = new int[totalSampleCount]; System.Array.Copy(tmp2, 0, tmp, 0, tmp.Length); sorted = true; } int collectedSampleCount = 0; int numSamplesCollected = 0; foreach (int count in tmp) { if (count >= _minCount) { collectedSampleCount += count; numSamplesCollected++; } else { if (sorted) { break; } } } double distScore = CalculateDistributionScore(tmp, collectedSampleCount, numSamplesCollected, totalSampleCount); FacetCountStatistics stats = new FacetCountStatistics(); stats.Distribution = distScore; stats.NumSamplesCollected = numSamplesCollected; stats.CollectedSampleCount = collectedSampleCount; stats.TotalSampleCount = totalSampleCount; return(stats); }
public virtual FacetCountStatistics generateStatistic(int[] distribution, int n) { int[] tmp = distribution; int totalSampleCount = distribution.Length; bool sorted = false; if (n > 0) { totalSampleCount = Math.Min(n, tmp.Length); // this is crappy, to be made better with a pq int[] tmp2 = new int[distribution.Length]; System.Array.Copy(distribution, 0, tmp2, 0, distribution.Length); System.Array.Sort(tmp2); tmp = new int[totalSampleCount]; System.Array.Copy(tmp2, 0, tmp, 0, tmp.Length); sorted = true; } int collectedSampleCount = 0; int numSamplesCollected = 0; foreach (int count in tmp) { if (count >= _minCount) { collectedSampleCount += count; numSamplesCollected++; } else { if (sorted) break; } } double distScore = calculateDistributionScore(tmp, collectedSampleCount, numSamplesCollected, totalSampleCount); FacetCountStatistics stats = new FacetCountStatistics(); stats.setDistribution(distScore); stats.setNumSamplesCollected(numSamplesCollected); stats.setCollectedSampleCount(collectedSampleCount); stats.setTotalSampleCount(totalSampleCount); return stats; }
public override bool Equals(object o) { bool ret = false; if (o is FacetCountStatistics) { FacetCountStatistics stat = (FacetCountStatistics)o; if (this.CollectedSampleCount == stat.CollectedSampleCount && this.NumSamplesCollected == stat.NumSamplesCollected && this.TotalSampleCount == stat.TotalSampleCount && this.Distribution == stat.Distribution) { ret = true; } } return(ret); }