/// <inheritdoc cref="Entropy.FromCaloriesPerKelvin(double)"/> public static Entropy CaloriesPerKelvin(this decimal value) => Entropy.FromCaloriesPerKelvin(Convert.ToDouble(value));
/// <inheritdoc cref="Entropy.FromKilocaloriesPerKelvin(UnitsNet.QuantityValue)" /> public static Entropy KilocaloriesPerKelvin <T>(this T value) => Entropy.FromKilocaloriesPerKelvin(Convert.ToDouble(value));
/// <inheritdoc cref="Entropy.FromKilojoulesPerDegreeCelsius(UnitsNet.QuantityValue)" /> public static Entropy KilojoulesPerDegreeCelsius <T>(this T value) => Entropy.FromKilojoulesPerDegreeCelsius(Convert.ToDouble(value));
public static void Main(string[] args) { DicConsole.WriteLineEvent += System.Console.WriteLine; DicConsole.WriteEvent += System.Console.Write; DicConsole.ErrorWriteLineEvent += System.Console.Error.WriteLine; Settings.Settings.LoadSettings(); Statistics.LoadStats(); if (Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.ShareStats) { Statistics.SubmitStats(); } Parser.Default.ParseArguments(args, typeof(AnalyzeOptions), typeof(BenchmarkOptions), typeof(ChecksumOptions), typeof(CompareOptions), typeof(ConfigureOptions), typeof(ConvertImageOptions), typeof(CreateSidecarOptions), typeof(DecodeOptions), typeof(DeviceInfoOptions), typeof(DeviceReportOptions), typeof(DumpMediaOptions), typeof(EntropyOptions), typeof(ExtractFilesOptions), typeof(FormatsOptions), typeof(ImageInfoOptions), typeof(ListDevicesOptions), typeof(ListEncodingsOptions), typeof(ListOptionsOptions), typeof(LsOptions), typeof(MediaInfoOptions), typeof(MediaScanOptions), typeof(PrintHexOptions), typeof(StatsOptions), typeof(VerifyOptions)) .WithParsed <AnalyzeOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Analyze.DoAnalyze(opts); }).WithParsed <CompareOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Compare.DoCompare(opts); }).WithParsed <ChecksumOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Checksum.DoChecksum(opts); }).WithParsed <EntropyOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Entropy.DoEntropy(opts); }).WithParsed <VerifyOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Verify.DoVerify(opts); }).WithParsed <PrintHexOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Commands.PrintHex.DoPrintHex(opts); }).WithParsed <DecodeOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Decode.DoDecode(opts); }).WithParsed <DeviceInfoOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); DeviceInfo.DoDeviceInfo(opts); }).WithParsed <MediaInfoOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); MediaInfo.DoMediaInfo(opts); }).WithParsed <MediaScanOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); MediaScan.DoMediaScan(opts); }).WithParsed <FormatsOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Formats.ListFormats(opts); }).WithParsed <BenchmarkOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Benchmark.DoBenchmark(opts); }).WithParsed <CreateSidecarOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); CreateSidecar.DoSidecar(opts); }).WithParsed <DumpMediaOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); DumpMedia.DoDumpMedia(opts); }).WithParsed <DeviceReportOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); DeviceReport.DoDeviceReport(opts); }).WithParsed <LsOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); Ls.DoLs(opts); }).WithParsed <ExtractFilesOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); ExtractFiles.DoExtractFiles(opts); }).WithParsed <ListDevicesOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); ListDevices.DoListDevices(opts); }).WithParsed <ListEncodingsOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); ListEncodings.DoList(); }).WithParsed <ListOptionsOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); ListOptions.DoList(); }).WithParsed <ConvertImageOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); ConvertImage.DoConvert(opts); }).WithParsed <ImageInfoOptions>(opts => { if (opts.Debug) { DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; } if (opts.Verbose) { DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; } PrintCopyright(); ImageInfo.GetImageInfo(opts); }).WithParsed <ConfigureOptions>(opts => { PrintCopyright(); Configure.DoConfigure(); }).WithParsed <StatsOptions>(opts => { PrintCopyright(); Commands.Statistics.ShowStats(); }).WithNotParsed(errs => Environment.Exit(1)); Statistics.SaveStats(); }
public UniqueIdRestorer(Entropy entropy) { _controlUniqueIds = entropy.ControlUniqueIds; _nextId = (_controlUniqueIds.Any() ? Math.Max(2, _controlUniqueIds.Values.Max()) : 2) + 1; }
public void CompareToThrowsOnTypeMismatch() { Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.Throws <ArgumentException>(() => jouleperkelvin.CompareTo(new object())); }
public void EqualsReturnsFalseOnTypeMismatch() { Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.False(jouleperkelvin.Equals(new object())); }
public void TemperatureDeltaTimesEntropyEqualsEnergy() { Energy energy = TemperatureDelta.FromKelvins(20) * Entropy.FromJoulesPerKelvin(4); Assert.Equal(Energy.FromJoules(80), energy); }
public static Entropy CaloriesPerKelvin<T>(this T value) => Entropy.FromCaloriesPerKelvin(Convert.ToDecimal(value));
public void Update(UpdateArgs args) { // See if we have a new category if (currentCategory == null) { // Create a category and force the first credit to show ChooseCategory(); Debug("Starting category: {0}", currentCategory); newSeconds = 0; } // If we don't have a category, we are done if (currentCategory == null) { Game.GameMode = new MainMenuMode(); return; } // Update any of the displayed ones LinkedList <CreditsLine> tmpList = new LinkedList <CreditsLine>(); tmpList.AddAll(displayed); foreach (CreditsLine cl in tmpList) { // Add the time cl.SecondsDisplayed += args.SecondsSinceLastUpdate; // If we exceeded the life, kill it if (cl.SecondsDisplayed > cl.SecondsToLive) { displayed.Remove(cl); sprites.Remove(cl.Sprite); Debug("Removing credit line: {0}", cl.Name); } } // If the displayed and pending list are empty, then we // are done if (displayed.Count == 0 && pending.Count == 0) { Debug("Finished category: {0}", currentCategory); currentCategory = null; return; } // See if we are showing a new one newSeconds -= args.SecondsSinceLastUpdate; if (slots > 0 && newSeconds <= 0 && pending.Count > 0) { // Reset the counter newSeconds = 0.2; // See if we have too many if (displayed.Count <= slots) { // Pick a random location for this int kill = slots * 2; while (true) { // Check the kill if (kill-- < 0) { break; } // Set up some variables int row = Entropy.Next(0, slots); float y = row * CreditsLine.FontSize + FontSize * 2; bool found = false; foreach (CreditsLine cl0 in displayed) { if (cl0.Point.Y == y) { found = true; break; } } // If we found something, try again if (found) { continue; } // Add a new one CreditsLine cl = pending.RemoveFirst(); displayed.Add(cl); cl.Point = new PointF( Entropy.NextFloat(sprites.Size.Width - cl.Sprite.Size.Width - 160) + 80, y); sprites.Add(cl.Sprite); break; } } } // Update the sprites sprites.Update(args); }
public void EntropyTimesTemperatureDeltaEqualsEnergy() { Energy energy = Entropy.FromKilojoulesPerKelvin(3) * TemperatureDelta.FromKelvins(7); Assert.Equal(Energy.FromKilojoules(21), energy); }
/// <inheritdoc cref="Entropy.FromJoulesPerDegreeCelsius(double?)"/> public static Entropy?JoulesPerDegreeCelsius(this double?value) => Entropy.FromJoulesPerDegreeCelsius(value);
/// <inheritdoc cref="Entropy.FromJoulesPerDegreeCelsius(double)"/> public static Entropy JoulesPerDegreeCelsius(this long value) => Entropy.FromJoulesPerDegreeCelsius(value);
/// <inheritdoc cref="Entropy.FromCaloriesPerKelvin(double?)"/> public static Entropy?CaloriesPerKelvin(this decimal?value) => Entropy.FromCaloriesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <summary>Get <see cref="Entropy"/> from <see cref="SpecificEntropy"/> times <see cref="Mass"/>.</summary> public static Entropy operator *(SpecificEntropy specificEntropy, Mass mass) { return(Entropy.FromJoulesPerKelvin(specificEntropy.JoulesPerKilogramKelvin * mass.Kilograms)); }
public static Entropy JoulesPerDegreeCelsius<T>(this T value) => Entropy.FromJoulesPerDegreeCelsius(Convert.ToDecimal(value));
private Node BuildTree(Matrix x, Vector y, int depth, List <int> used) { // reached depth limit or all labels are the same if (depth < 0 || y.Distinct().Count() == 1) { return new Node { IsLeaf = true, Label = y.Mode() } } ; double bestGain = -1; int bestFeature = -1; double[] splitValues = new double[] { }; Impurity measure = null; for (int i = 0; i < x.Cols; i++) { var feature = x[i, VectorType.Column]; var fd = Description.Features[i]; // is feature discrete? ie enum or bool? var discrete = fd.Type.IsEnum || fd.Type == typeof(bool); switch (Type) { case ImpurityType.Error: if (!discrete) { measure = Error.Of(y) .Given(feature) .WithWidth(Width); } else { measure = Error.Of(y) .Given(feature); } break; case ImpurityType.Entropy: if (!discrete) { measure = Entropy.Of(y) .Given(feature) .WithWidth(Width); } else { measure = Entropy.Of(y) .Given(feature); } break; case ImpurityType.Gini: if (!discrete) { measure = Gini.Of(y) .Given(feature) .WithWidth(Width); } else { measure = Gini.Of(y) .Given(feature); } break; } double gain = measure.RelativeGain(); if (gain > bestGain && !used.Contains(i)) { bestGain = gain; bestFeature = i; splitValues = measure.SplitValues; } } // uh oh, need to return something? // a weird node of some sort... // but just in case... if (bestFeature == -1) { return new Node { IsLeaf = true, Label = y.Mode() } } ; used.Add(bestFeature); Node n = new Node(); n.Gain = bestGain; // measure has a width property set // meaning its a continuous var // (second conditional indicates // a width that has range values) var bestFD = Description.Features[bestFeature]; // multiway split - constant fan-out width (non-continuous) if (bestFD.Type.IsEnum || bestFD.Type == typeof(bool)) { n.Children = new Node[splitValues.Length]; for (int i = 0; i < n.Children.Length; i++) { var slice = x.Indices(v => v[bestFeature] == splitValues[i], VectorType.Row); n.Children[i] = BuildTree(x.Slice(slice, VectorType.Row), y.Slice(slice), depth - 1, used); } n.Segmented = false; } // continuous split with built in ranges else { // since this is in ranges, need each slot // represents two boundaries n.Children = new Node[measure.Width]; for (int i = 0; i < n.Children.Length; i++) { var slice = x.Indices( v => v[bestFeature] >= splitValues[i] && v[bestFeature] < splitValues[i + 1], VectorType.Row); n.Children[i] = BuildTree(x.Slice(slice, VectorType.Row), y.Slice(slice), depth - 1, used); } n.Segmented = true; } n.IsLeaf = false; n.Feature = bestFeature; n.Values = splitValues; return(n); }
public static Entropy MegajoulesPerKelvin<T>(this T value) => Entropy.FromMegajoulesPerKelvin(Convert.ToDecimal(value));
public void CompareToThrowsOnNull() { Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.Throws <ArgumentNullException>(() => jouleperkelvin.CompareTo(null)); }
public void EnergyDividedByTemperatureDeltaEqualsEntropy() { Entropy e = Energy.FromJoules(16) / TemperatureDelta.FromKelvins(8); Assert.Equal(Entropy.FromJoulesPerKelvin(2), e); }
public void EqualsReturnsFalseOnNull() { Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.False(jouleperkelvin.Equals(null)); }
public void EnergyDividedByEntropyEqualsTemperatureDelta() { TemperatureDelta t = Energy.FromJoules(15) / Entropy.FromJoulesPerKelvin(3); Assert.Equal(TemperatureDelta.FromKelvins(5), t); }
public override void SetStaticDefaults() { DisplayName.SetDefault("Magnus Kirudo"); Tooltip.SetDefault(""); customGlowMask = Entropy.SetStaticDefaultsGlowMask(this); }
public void EntropyCalculationIsCorrect() { var e = Entropy.Calculate(data.Rows.Select(r => r.lable).ToArray()); Assert.That(e, Is.EqualTo(0.940).Within(0.001)); }
/// <inheritdoc cref="Entropy.FromJoulesPerKelvin(UnitsNet.QuantityValue)" /> public static Entropy JoulesPerKelvin <T>(this T value) => Entropy.FromJoulesPerKelvin(Convert.ToDouble(value));
public void TestMinEntropy() { var data = new[] { "A", "A", "A", "A", "A", "A", "A" }; Assert.AreEqual(0d, Entropy.Calculate(data), 0.0001); }
public static Entropy?KilocaloriesPerKelvin <T>(this T?value) where T : struct => Entropy.FromKilocaloriesPerKelvin(value == null ? (double?)null : Convert.ToDouble(value.Value));
public void TestHighEntropy2() { var data = new[] { "A", "A", "A", "A", "C", "C", "D", "F" }; Assert.AreEqual(1.75d, Entropy.Calculate(data), 0.0001); }
public static Entropy?KilojoulesPerDegreeCelsius <T>(this T?value) where T : struct => Entropy.FromKilojoulesPerDegreeCelsius(value == null ? (double?)null : Convert.ToDouble(value.Value));
/// <inheritdoc cref="Entropy.FromCaloriesPerKelvin(double?)"/> public static Entropy?CaloriesPerKelvin(this float?value) => Entropy.FromCaloriesPerKelvin(value);