public void CanSampleSequence() { var n = new Laplace(); var ied = n.Samples(); GC.KeepAlive(ied.Take(5).ToArray()); }
//public void ApplySobel(int xorder=1, int yorder =1, int apetureSize =17,int gray_threshold=124, int white_threshold=255) //{ // if (_ImageInput == null) // { // return; // } // Image<Gray, byte> imgGray = _ImageInput.Convert<Gray, byte>(); // Image<Gray, float> imgSobel = new Image<Gray, float>(_ImageInput.Width, _ImageInput.Height, new Gray(0)); // imgSobel = imgGray.Sobel(xorder,yorder,apetureSize); // var imgBinarize = imgSobel.Convert<Gray, byte>().ThresholdBinary(new Gray(gray_threshold), new Gray(white_threshold)); // imageBox1.Image = imgBinarize; //} private void laplacianToolStripMenuItem_Click(object sender, EventArgs e) { Laplace laplace = new Laplace(); laplace.setLaplaceInput(_ImageInput); imageBox1.Image = laplace.ApplyLaplace(); }
private static double Noise(double S, double eps) { var scale = (S / eps); var L = new Laplace(0, scale); return(L.Sample()); }
public void CanCreateLaplace(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Location); Assert.AreEqual(scale, n.Scale); }
/// <summary> /// The calculation Of the dimensionless wellbore pressure drop with skin for homogeneous reservoir. /// </summary> /// <param name="td">dimensionless time</param> /// <param name="cd">dimensionless wellbore storage</param> /// <param name="skinFactor">skin factor</param> /// <returns></returns> public static double PwdR(double td, double cd, double skinFactor) { Condition.Requires(td, nameof(td)).IsGreaterOrEqual(0.0); Condition.Requires(cd, nameof(cd)).IsGreaterOrEqual(0.0); return(Laplace.InverseTransform((x) => PwdRinLaplaceSpace(x, cd, skinFactor), td)); }
public void CanCreateLaplace() { var n = new Laplace(); Assert.AreEqual(0.0, n.Location); Assert.AreEqual(1.0, n.Scale); }
public void ValidateToString() { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; var n = new Laplace(-1d, 2d); Assert.AreEqual("Laplace(μ = -1, b = 2)", n.ToString()); }
public void Laplacian(OpenFOAMGrid grid, int DgDegree) { // grid, etc // ========= GridData grd = grid.GridData; var b = new Basis(grd, DgDegree); var map = new UnsetteledCoordinateMapping(b); var L = new Laplace(1.3, grd.Cells.cj); var op = new SpatialOperator(1, 0, 1, QuadOrderFunc.Linear(), "T", "c1"); op.EquationComponents["c1"].Add(L); op.Commit(); // evaluate operator // ================= var Mtx = new BlockMsrMatrix(map, map); double[] B = new double[map.LocalLength]; var eval = op.GetMatrixBuilder(map, null, map); eval.ComputeMatrix(Mtx, B); // return data // =========== throw new NotImplementedException("todo"); }
private static void SolveEq(DataSet data) { if (data.XVals.Length == 0 || data.Variables.Count == 0) { return; } double R = data.Variables[0].ConstValue; double w = data.Variables[1].ConstValue; double Kon = data.Variables[2].ConstValue; double Koff = data.Variables[3].ConstValue; double Df = data.Variables[4].ConstValue; double Ceq = data.Variables[5].ConstValue; double Feq = 1 - Ceq; data.FitYVals = new double[data.XVals.Length]; Laplace lap = new Laplace(); lap.InitStehfest(14); for (int t = 1; t < data.XVals.Length; t++) { //data.FitYVals[0][t] = MathNet.Numerics.SpecialFunctions.BesselK1(data.XVals[t]); //data.YVals[0][t] = MathNet.Numerics.SpecialFunctions.BesselI1(data.XVals[t]); //data.FitYVals[0][t] = Accord.Math.Bessel.I(data.XVals[t]); //data.FitYVals[0][t] = Accord.Math.Bessel.Y(data.XVals[t]); - it is not modified!!! data.FitYVals[t] = (R)*lap.InverseTransform(R, w, Feq, Ceq, Kon, Koff, Df, data.XVals[t]); } }
public void CanCreateLaplace([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Location); Assert.AreEqual(scale, n.Scale); }
private double FunctionValueHalfTime(INonlinearModel model, int rowVid, ValuesByIndex values, bool newValues) { foreach (Variable c in data.Variables) { if (c.ConstName == "T1/2") { c.ConstValue = values[model.GetIndexFromKey(c.ConstName)]; break; } } double R = data.Variables[0].ConstValue; double w = data.Variables[1].ConstValue; double Kon = data.Variables[2].ConstValue; double Koff = data.Variables[3].ConstValue; double Df = data.Variables[4].ConstValue; double Ceq = data.Variables[5].ConstValue; double Feq = 1 - Ceq; double Tht = data.Variables[6].ConstValue; data.FitYVals = new double[data.XVals.Length]; Laplace lap = new Laplace(); lap.InitStehfest(14); return(Math.Abs((R)*lap.InverseTransform(R, w, Feq, Ceq, Kon, Koff, Df, Tht) - 0.5 * R)); }
public void ValidateDensity(double location, double scale, double x) { var n = new Laplace(location, scale); double expected = Math.Exp(-Math.Abs(x - location) / scale) / (2.0 * scale); Assert.AreEqual(expected, n.Density(x)); Assert.AreEqual(expected, Laplace.PDF(location, scale, x)); }
public void ValidateCumulativeDistribution(double location, double scale, double x) { var n = new Laplace(location, scale); double expected = 0.5 * (1.0 + (Math.Sign(x - location) * (1.0 - Math.Exp(-Math.Abs(x - location) / scale)))); Assert.AreEqual(expected, n.CumulativeDistribution(x)); Assert.AreEqual(expected, Laplace.CDF(location, scale, x)); }
public void ValidateDensityLn(double location, double scale, double x) { var n = new Laplace(location, scale); double expected = -Math.Log(2.0 * scale) - (Math.Abs(x - location) / scale); Assert.AreEqual(expected, n.DensityLn(x)); Assert.AreEqual(expected, Laplace.PDFLn(location, scale, x)); }
private void apeturesize_trackbar_Scroll(object sender, EventArgs e) { int apeturesize = apeturesize_trackbar.Value; apeturesize_label.Text = apeturesize.ToString("ApetureSize :" + apeturesize); Laplace laplace = new Laplace(); laplace.ApplyLaplace(apeturesize); }
public void ValidateDensityLn( [Values(0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity)] double location, [Values(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double scale, [Values(1.5, 2.8, -5.4, -4.9, 2.0, 5.5, -0.0, Double.PositiveInfinity, 5.0, -1.0, -1.0, 2.5, 2.0, 15.0, 89.3, -0.1, 0.1, -6.1, -10.0, 2.0, -5.1)] double x) { var n = new Laplace(location, scale); Assert.AreEqual(-Math.Log(2.0 * scale) - (Math.Abs(x - location) / scale), n.DensityLn(x)); }
public void ValidateCumulativeDistribution( [Values(0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity, 0.0, 1.0, -1.0, 5.0, -5.0, Double.PositiveInfinity, Double.NegativeInfinity)] double location, [Values(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double scale, [Values(1.5, 2.8, -5.4, -4.9, 2.0, 5.5, -0.0, Double.PositiveInfinity, 5.0, -1.0, -1.0, 2.5, 2.0, 15.0, 89.3, -0.1, 0.1, -6.1, -10.0, 2.0, -5.1)] double x) { var n = new Laplace(location, scale); Assert.AreEqual(0.5 * (1.0 + (Math.Sign(x - location) * (1.0 - Math.Exp(-Math.Abs(x - location) / scale)))), n.CumulativeDistribution(x)); }
public void ValidateLaplaceDensityEquivalence(double location, double scale, double x) { var n = new SkewedGeneralizedT(location, scale, 0, 1, double.PositiveInfinity); var b = scale / Math.Sqrt(2.0); var l = new Laplace(location, b); AssertHelpers.AlmostEqualRelative(l.Density(x), n.Density(x), 8); AssertHelpers.AlmostEqualRelative(l.DensityLn(x), n.DensityLn(x), 8); }
public static void laplace_cdf_values_test() //****************************************************************************80 // // Purpose: // // LAPLACE_CDF_VALUES_TEST tests LAPLACE_CDF_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 June 2007 // // Author: // // John Burkardt // { double beta = 0; double fx = 0; double mu = 0; double x = 0; Console.WriteLine(""); Console.WriteLine("LAPLACE_CDF_VALUES_TEST:"); Console.WriteLine(" LAPLACE_CDF_VALUES returns values of "); Console.WriteLine(" the Laplace Cumulative Density Function."); Console.WriteLine(""); Console.WriteLine(" Mu Beta X CDF(X)"); Console.WriteLine(""); int n_data = 0; for (;;) { Laplace.laplace_cdf_values(ref n_data, ref mu, ref beta, ref x, ref fx); if (n_data == 0) { break; } Console.WriteLine(" " + mu.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + beta.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + x.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + fx.ToString("0.################").PadLeft(24) + ""); } }
protected override void InitializeDecoding(string src, int passHash, int lsbIndicator) { base.InitializeDecoding(src, passHash, lsbIndicator); var filter = new Laplace(Bitmap, LsbIndicator, 8); IDictionary <Pixel, int> filtered = new Dictionary <Pixel, int>(); for (var x = 0; x < Bitmap.Width; x++) { for (var y = 0; y < Bitmap.Height; y++) { filtered.Add(new Pixel(x, y), filter.GetValue(x, y)); } } mLaplaceValues = filtered.OrderByDescending(key => key.Value); }
private void GenerateShips() { var filter = new Laplace(Bitmap, LsbIndicator, 8); IDictionary <Pixel, int> filtered = new Dictionary <Pixel, int>(); for (var x = 0; x < Bitmap.Width; x++) { for (var y = 0; y < Bitmap.Height; y++) { filtered.Add(new Pixel(x, y), filter.GetValue(x, y)); } } var ordered = filtered.OrderByDescending(key => key.Value); //TODO: dynamic maybe? Top 100 mShips = new HashSet <Pixel>(ordered.Select((x, y) => x.Key).Take(50)); }
protected override double Calculation(LockBitmap originalBmp, LockBitmap steganoBmp) { var origFiltered = new Laplace(originalBmp, 0, 8); var stegoFiltered = new Laplace(steganoBmp, 0, 8); var originalDiff = 0.0; var totalDiff = 0.0; for (var y = 0; y < originalBmp.Height; y++) { for (var x = 0; x < originalBmp.Width; x++) { //TODO Shouldnt that be the other direction? First TOTAL and second ORIGINAL? originalDiff += Math.Pow(origFiltered.GetValue(x, y) - stegoFiltered.GetValue(x, y), 2); totalDiff += Math.Pow(origFiltered.GetValue(x, y), 2); } } return(originalDiff / totalDiff); }
unsafe public static void Laplacian(ref int GridRef, ref int DgDegree, out int ierr) { try { // grid, etc // ========= GridData grd = null;// (GridData)(Infrastructure.GetObject(GridRef)); var b = new Basis(grd, DgDegree); var map = new UnsetteledCoordinateMapping(b); var L = new Laplace(1.3, grd.Cells.cj); var op = new SpatialOperator(1, 0, 1, QuadOrderFunc.Linear(), "T", "c1"); op.EquationComponents["c1"].Add(L); op.Commit(); // evaluate operator // ================= var Mtx = new BlockMsrMatrix(map, map); double[] B = new double[map.LocalLength]; var eval = op.GetMatrixBuilder(map, null, map); eval.ComputeMatrix(Mtx, B); // return data // =========== throw new NotImplementedException("todo"); } catch (Exception e) { ierr = Infrastructure.ErrorHandler(e); } ierr = 0; }
public void CanSample() { var n = new Laplace(); n.Sample(); }
public void ValidateStdDev(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Sqrt(2.0) * scale, n.StdDev); }
public void ValidateMinimum() { var n = new Laplace(); Assert.AreEqual(Double.NegativeInfinity, n.Minimum); }
public void ValidateEntropy(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Log(2.0 * Constants.E * scale), n.Entropy); }
public void CanSampleSequence() { var n = new Laplace(); var ied = n.Samples(); ied.Take(5).ToArray(); }
public void ValidateMean(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Mean); }
public void SetLocationFailsWithNegativeLocation() { var n = new Laplace(); Assert.Throws<ArgumentOutOfRangeException>(() => n.Location = Double.NaN); }
public void ValidateSkewness(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(0.0, n.Skewness); }
public void ValidateMedian(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(location, n.Median); }
public void ValidateDensityLn(double location, double scale, double x) { var n = new Laplace(location, scale); Assert.AreEqual(-Math.Log(2.0 * scale) - (Math.Abs(x - location) / scale), n.DensityLn(x)); }
public void ValidateCumulativeDistribution(double location, double scale, double x) { var n = new Laplace(location, scale); Assert.AreEqual(0.5 * (1.0 + (Math.Sign(x - location) * (1.0 - Math.Exp(-Math.Abs(x - location) / scale)))), n.CumulativeDistribution(x)); }
public void ValidateMode(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual<double>(location, n.Mode); }
public void SetScaleFailsWithNegativeScale(double scale) { var n = new Laplace(); n.Scale = scale; }
public void SetScaleFailsWithNegativeScale([Values(0.0, -1.0, -5.0, Double.NegativeInfinity, Double.NaN)] double scale) { var n = new Laplace(); Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale); }
public void CanSetLocation(double location) { var n = new Laplace(); n.Location = location; }
public void ValidateStdDev(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Constants.Sqrt2 * scale, n.StdDev); }
public void ValidateEntropy([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Log(2.0 * Constants.E * scale), n.Entropy); }
public void ValidateMaximum() { var n = new Laplace(); Assert.AreEqual(Double.PositiveInfinity, n.Maximum); }
public void ValidateVariance(double location, double scale) { var n = new Laplace(location, scale); Assert.AreEqual(2.0 * scale * scale, n.Variance); }
public void ValidateSkewness([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) { var n = new Laplace(location, scale); Assert.AreEqual(0.0, n.Skewness); }
public void SetScaleFailsWithNegativeScale(double scale) { var n = new Laplace(); Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale); }
public void ValidateStdDev([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) { var n = new Laplace(location, scale); Assert.AreEqual(Math.Sqrt(2.0) * scale, n.StdDev); }
public void ValidateDensity(double location, double scale, double x) { var n = new Laplace(location, scale); Assert.AreEqual<double>(Math.Exp(-Math.Abs(x - location) / scale) / (2.0 * scale), n.Density(x)); }
public void ValidateToString() { var n = new Laplace(-1.0, 2.0); Assert.AreEqual("Laplace(Location = -1, Scale = 2)", n.ToString()); }
public void SetLocationFailsWithNegativeLocation(double location) { var n = new Laplace(); n.Location = location; }
public void ValidateVariance([Values(Double.NegativeInfinity, -5.0 - 1.0, 0.0, 1.0, 5.0, Double.PositiveInfinity)] double location, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale) { var n = new Laplace(location, scale); Assert.AreEqual(2.0 * scale * scale, n.Variance); }
public void CanSetScale(double scale) { var n = new Laplace(); n.Scale = scale; }