本文整理汇总了C#中Histogram类的典型用法代码示例。如果您正苦于以下问题:C# Histogram类的具体用法?C# Histogram怎么用?C# Histogram使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Histogram类属于命名空间,在下文中一共展示了Histogram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testGetEstimatedFootprintInBytes
public void testGetEstimatedFootprintInBytes()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
/*
* largestValueWithSingleUnitResolution = 2 * (10 ^ numberOfSignificantValueDigits);
* subBucketSize = roundedUpToNearestPowerOf2(largestValueWithSingleUnitResolution);
* expectedHistogramFootprintInBytes = 512 +
* ({primitive type size} / 2) *
* (log2RoundedUp((highestTrackableValue) / subBucketSize) + 2) *
* subBucketSize
*/
long largestValueWithSingleUnitResolution = 2 * (long) Math.Pow(10, numberOfSignificantValueDigits);
int subBucketCountMagnitude = (int)Math.Ceiling(Math.Log(largestValueWithSingleUnitResolution) / Math.Log(2));
int subBucketSize = (int) Math.Pow(2, (subBucketCountMagnitude));
long expectedSize = 512 +
((8 *
((long)(
Math.Ceiling(
Math.Log(highestTrackableValue / subBucketSize)
/ Math.Log(2)
)
+ 2)) *
(1 << (64 - MiscUtilities.numberOfLeadingZeros(2 * (long)Math.Pow(10, numberOfSignificantValueDigits))))
) / 2);
Assert.assertEquals(expectedSize, histogram.getEstimatedFootprintInBytes());
}
示例2: HistogramDataAccessTest
static HistogramDataAccessTest()
{
histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
scaledHistogram = new Histogram(1000, highestTrackableValue * 512, numberOfSignificantValueDigits);
rawHistogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
scaledRawHistogram = new Histogram(1000, highestTrackableValue * 512, numberOfSignificantValueDigits);
// Log hypothetical scenario: 100 seconds of "perfect" 1msec results, sampled
// 100 times per second (10,000 results), followed by a 100 second pause with
// a single (100 second) recorded result. Recording is done indicating an expected
// interval between samples of 10 msec:
for (int i = 0; i < 10000; i++)
{
histogram.recordValueWithExpectedInterval(1000 /* 1 msec */, 10000 /* 10 msec expected interval */);
scaledHistogram.recordValueWithExpectedInterval(1000 * 512 /* 1 msec */, 10000 * 512 /* 10 msec expected interval */);
rawHistogram.recordValue(1000 /* 1 msec */);
scaledRawHistogram.recordValue(1000 * 512/* 1 msec */);
}
histogram.recordValueWithExpectedInterval(100000000L /* 100 sec */, 10000 /* 10 msec expected interval */);
scaledHistogram.recordValueWithExpectedInterval(100000000L * 512 /* 100 sec */, 10000 * 512 /* 10 msec expected interval */);
rawHistogram.recordValue(100000000L /* 100 sec */);
scaledRawHistogram.recordValue(100000000L * 512 /* 100 sec */);
postCorrectedHistogram = rawHistogram.copyCorrectedForCoordinatedOmission(10000 /* 10 msec expected interval */);
postCorrectedScaledHistogram = scaledRawHistogram.copyCorrectedForCoordinatedOmission(10000 * 512 /* 10 msec expected interval */);
}
示例3: Show
/// <summary>
/// Display the specific histogram
/// </summary>
/// <param name="hist">The histogram to be displayed</param>
/// <param name="title">The name of the histogram</param>
public static void Show(Histogram hist, string title)
{
HistogramViewer viewer = new HistogramViewer();
viewer.HistogramCtrl.AddHistogram(title, Color.Black, hist);
viewer.HistogramCtrl.Refresh();
viewer.Show();
}
示例4: HistogramView
/// <summary>
/// Constructs a new instance of the HistogramView.
/// </summary>
///
public HistogramView()
{
InitializeComponent();
this.histogram = new Histogram();
graphBars = new ZedGraph.BarItem(String.Empty);
graphBars.Color = Color.DarkBlue;
zedGraphControl.GraphPane.Title.FontSpec.IsBold = true;
zedGraphControl.GraphPane.Title.FontSpec.Size = 32f;
zedGraphControl.GraphPane.Title.IsVisible = true;
zedGraphControl.GraphPane.XAxis.Type = AxisType.Text;
zedGraphControl.GraphPane.XAxis.Title.IsVisible = false;
zedGraphControl.GraphPane.XAxis.MinSpace = 0;
zedGraphControl.GraphPane.XAxis.MajorGrid.IsVisible = false;
zedGraphControl.GraphPane.XAxis.MinorGrid.IsVisible = false;
zedGraphControl.GraphPane.XAxis.MajorTic.IsBetweenLabels = true;
zedGraphControl.GraphPane.XAxis.MajorTic.IsInside = false;
zedGraphControl.GraphPane.XAxis.MajorTic.IsOpposite = false;
zedGraphControl.GraphPane.XAxis.MinorTic.IsAllTics = false;
zedGraphControl.GraphPane.XAxis.Scale.FontSpec.IsBold = true;
zedGraphControl.GraphPane.XAxis.Scale.FontSpec.IsAntiAlias = true;
zedGraphControl.GraphPane.YAxis.MinorTic.IsAllTics = false;
zedGraphControl.GraphPane.YAxis.MajorTic.IsOpposite = false;
zedGraphControl.GraphPane.YAxis.Title.Text = "Frequency";
zedGraphControl.GraphPane.YAxis.Title.FontSpec.Size = 24f;
zedGraphControl.GraphPane.YAxis.Title.FontSpec.IsBold = true;
zedGraphControl.GraphPane.Border.IsVisible = false;
zedGraphControl.GraphPane.BarSettings.MinBarGap = 0;
zedGraphControl.GraphPane.BarSettings.MinClusterGap = 0;
zedGraphControl.GraphPane.CurveList.Add(graphBars);
}
示例5: run
internal static ArrayList run(IList para)
{
bool reverse = false;
modshogun.init_shogun_with_defaults();
int order = (int)((int?)para[0]);
int gap = (int)((int?)para[1]);
string[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, DNA);
StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
feats.obtain_from_char(charfeat, order-1, order, gap, reverse);
Histogram histo = new Histogram(feats);
histo.train();
histo.get_histogram();
int num_examples = feats.get_num_vectors();
int num_param = histo.get_num_model_parameters();
DoubleMatrix out_likelihood = histo.get_log_likelihood();
double out_sample = histo.get_log_likelihood_sample();
ArrayList result = new ArrayList();
result.Add(histo);
result.Add(out_sample);
result.Add(out_likelihood);
modshogun.exit_shogun();
return result;
}
示例6: Evaluate_NormalSample
public void Evaluate_NormalSample()
{
var sample = Enumerable
.Range(1, 10)
.Select(n => new { p = Functions.NormalDistribution(n, 2.87f, 5), n = n })
.SelectMany(x => Enumerable.Range(1, (int)(x.p * 100)).Select(n => (x.n).OutOf(10)))
.ToList()
.AsQueryable();
var hist = new Histogram(0.02f);
var kde = new KernelDensityEstimator(0.02f);
var histF = hist.Evaluate(sample);
var kdeF = kde.Evaluate(sample);
var stdDevMu = Functions.MeanStdDev(sample);
Console.WriteLine("Mean\t{0}", stdDevMu.Item1);
Console.WriteLine("StdDev\t{0}", stdDevMu.Item2);
var hRes = Enumerable.Range(1, 10).Select(n => new { n = n, p = histF(n.OutOf(10)) });
var kRes = Enumerable.Range(1, 10).Select(n => kdeF(n.OutOf(10))).Normalise().ToList();
int i = 0;
foreach (var x in hRes)
{
var kr = kRes[i++];
Console.WriteLine("{0}\t{1}\t{2}", x.n, x.p.Value, kr.Value);
Assert.That(Math.Round(x.p.Value, 4), Is.EqualTo(Math.Round(kr.Value, 4)));
}
}
示例7: PermutationDistribution
public void PermutationDistribution()
{
// We want to test that GetRandomPermutation actually samples all permutations equally
// Don't let n get too big or we will have a ridiculously large number of bins
for (int n = 2; n < 8; n++) {
// Build a mapping that assign each permutation a unique integer index from 0 to (n! - 1)
Dictionary<Permutation, int> index = new Dictionary<Permutation, int>();
int count = 0;
foreach (Permutation p in Permutation.Permutations(n)) {
index.Add(p, count);
count++;
}
// Create a historgram of randomly generated permutation indexes
Histogram histogram = new Histogram(count);
Random rng = new Random(2);
for (int i = 0; i < 8 * count; i++) {
Permutation p = Permutation.GetRandomPermutation(n, rng);
histogram.Bins[index[p]].Increment();
}
//for (int i = 0; i < count; i++) {
// Console.WriteLine("{0} {1}", i, bins[i].Counts);
//}
TestResult result = histogram.ChiSquaredTest(new DiscreteUniformDistribution(0, count - 1));
Console.WriteLine(result.RightProbability);
Assert.IsTrue(result.RightProbability > 0.01);
}
}
示例8: Analyse_TimeSeries
public void Analyse_TimeSeries()
{
var now = DateTime.UtcNow;
var now_plusx = new Func<int, DateTime>(x => now.AddHours(x));
var width = TimeSpan.FromHours(1);
var hist = new Histogram(width.TotalMilliseconds);
var sample = new[] {
new { date = now, name = "a" },
new { date = now_plusx(1), name = "b" },
new { date = now_plusx(1), name = "c" },
new { date = now_plusx(3), name = "d" },
new { date = now_plusx(4), name = "e" },
new { date = now_plusx(6), name = "f" },
new { date = now_plusx(6), name = "g" },
new { date = now_plusx(8), name = "h" }
}.AsQueryable();
var histSample = hist.Analyse(sample, v => v.date);
Assert.That(histSample.Min, Is.EqualTo(now));
Assert.That(histSample.Max, Is.EqualTo(now_plusx(8)));
Assert.That(histSample.Total, Is.EqualTo(sample.Count()));
Assert.That(histSample.Width, Is.EqualTo(width));
Assert.That(histSample.Bins.Count, Is.EqualTo(9));
Assert.That(histSample.Bins[0], Is.EqualTo(1));
Assert.That(histSample.Bins[1], Is.EqualTo(2));
Assert.That(histSample.Bins[6], Is.EqualTo(2));
}
示例9: Hystogram_Dump_1
public void Hystogram_Dump_1()
{
const int CNT = 100000;
const int MAX_RND = 100;
var hist = new Histogram<int>("Random Histogram",
new Dimension<int>(
"ValBucket",
partCount: MAX_RND,
partitionFunc: (dim, v) => {
return v;// % 100;
},
partitionNameFunc: (i) => i.ToString()
)
);
// var rnd = new Random();
for(var i=0; i<CNT; i++)
{
// var r = rnd.Next(100);// ExternalRandomGenerator.Instance.NextScaledRandomInteger(0,100);
var r = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, MAX_RND);
hist.Sample( r );
// ExternalRandomGenerator.Instance.FeedExternalEntropySample( (int)NFX.OS.Computer.GetMemoryStatus().AvailablePhysicalBytes);
}
string output = hist.ToStringReport();
Console.WriteLine( output );
var countPerRandomSeed = CNT / (double)MAX_RND;
var tolerance = countPerRandomSeed * 0.15d;//Guarantees uniform random distribution. The lower the number, the more uniform gets
foreach(var he in hist)
Assert.IsTrue( he.Count >countPerRandomSeed-tolerance && he.Count < countPerRandomSeed+tolerance);
}
示例10: Main
public static void Main() {
bool reverse = false;
modshogun.init_shogun_with_defaults();
int order = 3;
int gap = 4;
String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");
StringCharFeatures charfeat = new StringCharFeatures(fm_train_dna, EAlphabet.DNA);
StringWordFeatures feats = new StringWordFeatures(charfeat.get_alphabet());
feats.obtain_from_char(charfeat, order-1, order, gap, reverse);
Histogram histo = new Histogram(feats);
histo.train();
double[] histogram = histo.get_histogram();
foreach(double item in histogram) {
Console.Write(item);
}
//int num_examples = feats.get_num_vectors();
//int num_param = histo.get_num_model_parameters();
//double[,] out_likelihood = histo.get_log_likelihood();
//double out_sample = histo.get_log_likelihood_sample();
modshogun.exit_shogun();
}
示例11: AddHistogram
/// <summary>
/// Add a plot of the 1D histogram. You should call the Refresh() function to update the control after all modification is complete.
/// </summary>
/// <param name="name">The name of the histogram</param>
/// <param name="color">The drawing color</param>
/// <param name="histogram">The 1D histogram to be drawn</param>
public void AddHistogram(String name, System.Drawing.Color color, Histogram histogram)
{
Debug.Assert(histogram.Dimension == 1, "Only 1D histogram is supported");
GraphPane pane = new GraphPane();
// Set the Title
pane.Title.Text = name;
pane.XAxis.Title.Text = "Color Intensity";
pane.YAxis.Title.Text = "Pixel Count";
#region draw the histogram
RangeF range = histogram.Ranges[0];
int binSize = histogram.BinDimension[0].Size;
float step = (range.Max - range.Min) / binSize;
float start = range.Min;
double[] bin = new double[binSize];
for (int binIndex = 0; binIndex < binSize; binIndex++)
{
bin[binIndex] = start;
start += step;
}
PointPairList pointList = new PointPairList(
bin,
Array.ConvertAll<float, double>(histogram.Data, System.Convert.ToDouble));
pane.AddCurve(name, pointList, color);
#endregion
zedGraphControl1.MasterPane.Add(pane);
}
示例12: AssertBinCounts
private static void AssertBinCounts(Histogram histogram, int[] counts)
{
Assert.IsTrue(histogram.BelowRangeBin.Counts == counts[0]);
for (int i = 0; i < histogram.Bins.Count; i++) {
Assert.IsTrue(histogram.Bins[i].Counts == counts[i + 1]);
}
Assert.IsTrue(histogram.AboveRangeBin.Counts == counts[histogram.Bins.Count + 1]);
}
示例13: Metric
protected Metric(double mean, double min, double max, long count, double accumulatedVariance, Histogram histogram)
{
Mean = mean;
Min = min;
Max = max;
Count = count;
this.accumulatedVariance = accumulatedVariance;
Histogram = histogram;
}
示例14: testConstructionArgumentGets
public void testConstructionArgumentGets()
{
Histogram histogram = new Histogram(highestTrackableValue, numberOfSignificantValueDigits);
Assert.assertEquals(1, histogram.getLowestTrackableValue());
Assert.assertEquals(highestTrackableValue, histogram.getHighestTrackableValue());
Assert.assertEquals(numberOfSignificantValueDigits, histogram.getNumberOfSignificantValueDigits());
Histogram histogram2 = new Histogram(1000, highestTrackableValue, numberOfSignificantValueDigits);
Assert.assertEquals(1000, histogram2.getLowestTrackableValue());
}
示例15: CorrelationScoreTable
public CorrelationScoreTable(ScoreMethod method, int intensityBins, double[] binEdges)
{
_method = method;
_binEdges = binEdges;
IntensityBins = null;
_intensityBinCount = intensityBins;
WorstScore = new Probability<int>(0);
_intensityHistogram = new Histogram<FitScore>(new CompareFitScoreByIntensity());
}