Exemple #1
0
        public void ValidateToString()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            var d = new Geometric(0.3);

            Assert.AreEqual("Geometric(p = 0.3)", d.ToString());
        }
Exemple #2
0
            public void Load()
            {
                BinaryFormatter formatter = new BinaryFormatter();

                using (FileStream fs = new FileStream(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "Geometrics.dat"), FileMode.OpenOrCreate))
                {
                    bool suc = true;
                    while (fs.Position < fs.Length)
                    {
                        try
                        {
                            Geometric elem = (Geometric)formatter.Deserialize(fs, null);
                            Glist.Add(elem);
                        }
                        catch (SerializationException)
                        {
                            MessageBox.Show("Похоже, одной из фигур больше нет в списке плагинов.");
                            suc = false;
                            break;
                        }
                    }
                    if (suc)
                    {
                        MessageBox.Show("Успешно загружено!");
                    }
                }
            }
        public void GeometricTest(double firstValue, double secondValue, double expected)
        {
            var calculator   = new Geometric();
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
        public void CanSampleSequence()
        {
            var d   = new Geometric(0.3);
            var ied = d.Samples();

            ied.Take(5).ToArray();
        }
Exemple #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="bitmap">Reference bitmap.</param>
        public BodyBackground(Bitmap bitmap, PointF location)
        {
            // Geometric.AddLine(new Point(0, 0), new Point(1, 1));
            // Geometric.AddRectangle(new System.Drawing.Rectangle(0, 0, 1, 1));
            // bitmap.Save("D:\\4545.jpg");
            if (bitmap != null)
            {
                Selected = false;
                Locked   = true;
                // if (Dimension.Width == 1 && Dimension.Height == 1)
                if (Dimension.IsEmpty)
                {
                    Geometric.AddRectangle(new System.Drawing.RectangleF(location.X, location.Y, bitmap.Width, bitmap.Height));
                }


                // Dimension = new SizeF(bitmap.Width, bitmap.Height);
                // var rec = Geometric.GetBounds();

                //bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
                //bitmap.RotateFlip(RotateFlipType.Rotate90FlipXY);
                _bitmap = bitmap;//.Clone() as Bitmap;
                this.Appearance.Image = bitmap;
            }
        }
Exemple #6
0
        public static void BnaderaJaponesa()
        {
            double f;
            double c;

            //int d;
            for (f = 0; f < 19; f++)
            {
                for (c = 0; c < 74; c++)
                {
                    if (c == 0 || c == 73 || f == 0 || f == 18)
                    {
                        System.Console.Write("*");
                    }
                    else if (Geometric.CalculateDistance2D(37, 10, c, f) < 5.0)
                    {
                        System.Console.Write("0");
                    }
                    else
                    {
                        System.Console.Write(" ");
                    }
                }
                System.Console.WriteLine();
            }
        }
Exemple #7
0
 public TabularFieldSettings GetFieldSettings(Control control)
 {
     if (fieldSettings != null)
     {
         fieldSettings.BoundsBox = Geometric.GetOptimalFieldSize(control.Size);
     }
     return(fieldSettings);
 }
Exemple #8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="bitmap">Reference bitmap.</param>
        public Image(Bitmap bitmap, RectangleF rec)
        {
            // Geometric.AddLine(new Point(0, 0), new Point(1, 1));
            Geometric.AddRectangle(rec);

            _bitmap = bitmap.Clone() as Bitmap;
            this.Appearance.Image = bitmap;
        }
Exemple #9
0
        /// <summary>
        /// 菱形
        /// </summary>
        private static void Geometric()
        {
            var geometric = new Geometric();

            Console.WriteLine("============菱形===========");
            geometric.Rin(5);
            geometric.Rin2(5);
            Console.WriteLine("===========================");
        }
Exemple #10
0
 protected Figure(Geometric geometric)
 {
     Geometric = geometric;
     Path      = new Path()
     {
         Data    = Geometric,
         Stretch = Stretch.Fill,
     };
 }
Exemple #11
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Text()
 {
     Geometric.Reset();
     Geometric.AddLine(0, 0, 1, 1);
     //Geometric.AddString(_displayedText, _font.FontFamily, (int)_font.Style, _font.Size, Geometric.GetBounds(), _stringFormat);
     // Geometric.FillMode = System.Drawing.Drawing2D.FillMode.Winding;
     this.Transformer.RotateOccurred += new RotateHandler(Transformer_RotateOccurred);
     ((PolygonAppearance)this.Appearance).BackgroundColor1 = Color.Black;
     ((PolygonAppearance)this.Appearance).BackgroundColor2 = Color.Black;
 }
        private bool GenerateDiscreteRandom()
        {
            My_Random_Discrete_Base rand = null;

            if (RadiobuttonDiscretteBernoulli.IsChecked == true)
            {
                double p = randomParametersDiscretteRandom.TextBoxParameterp.GetDoubleValue();
                rand = new Bernoulli(p);
            }
            if (RadiobuttonDiscretteBinomial.IsChecked == true)
            {
                long   n = randomParametersDiscretteRandom.TextBoxParametern.GetIntegerValue();
                double p = randomParametersDiscretteRandom.TextBoxParameterp.GetDoubleValue();
                rand = new Binomial(n, p);
            }
            if (RadiobuttonDiscretteEquilikely.IsChecked == true)
            {
                long a = randomParametersDiscretteRandom.TextBoxParametera.GetIntegerValue();
                long b = randomParametersDiscretteRandom.TextBoxParameterb.GetIntegerValue();
                rand = new Equilikely(a, b);
            }
            if (RadiobuttonDiscretteGeometric.IsChecked == true)
            {
                double p = randomParametersDiscretteRandom.TextBoxParameterp.GetDoubleValue();
                rand = new Geometric(p);
            }
            if (RadiobuttonDiscrettePascal.IsChecked == true)
            {
                long   n = randomParametersDiscretteRandom.TextBoxParametern.GetIntegerValue();
                double p = randomParametersDiscretteRandom.TextBoxParameterp.GetDoubleValue();
                rand = new Pascal(n, p);
            }
            if (RadiobuttonDiscrettePoisson.IsChecked == true)
            {
                double m = randomParametersDiscretteRandom.TextBoxParameterm.GetDoubleValue();
                rand = new Poisson(m);
            }
            if (RadiobuttonDiscretteSimple.IsChecked == true)
            {
                int d = randomParametersDiscretteRandom.TextBoxParameterRange.GetIntegerValue();
                rand = new SimpleDiscrete(d);
            }
            rand.SizeVector = genSettings.Size;

            if (timeUnitUserControlClock.TimeInterval.GetTimeUnitInFS() == 0)
            {
                MessageBox.Show("Time must be non zero", "Error!", MessageBoxButton.OK);
                return(false);
            }

            rand.TimeStep = timeUnitUserControlDiscretteRandom.TimeInterval;

            generator = rand;
            return(true);
        }
Exemple #13
0
        /// <summary>
        /// Called when a shape is removed.
        /// </summary>
        /// <param name="shape">Removed shape.</param>
        /// <param name="index">Removing index.</param>
        void _shapes_RemovedItem(IShape shape, int index)
        {
            (shape as Shape).Parent = null;

            Geometric.Reset();

            foreach (IShape grouppedShape in _shapes)
            {
                Geometric.AddPath(grouppedShape.Geometric, false);
            }
        }
        static void Main(string[] args)
        {
            float   z = -3.728099f;
            Vector3 a = new Vector3(-0.52486f, 0, z);
            Vector3 b = new Vector3(-4.176628f, 0, z);
            Vector3 p = new Vector3(0.433864f, 0, z);

            float thick = 0.24f;

            Console.WriteLine(Geometric.AlmostOnLine(a, b, thick, p));
        }
Exemple #15
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="bitmap">Reference bitmap.</param>
        public pActiveAnnotation(Bitmap bitmap, PointF location)
        {
            // Geometric.AddLine(new Point(0, 0), new Point(1, 1));
            Geometric.AddRectangle(new System.Drawing.RectangleF(location.X, location.Y, bitmap.Width, bitmap.Height));

            if (bitmap != null)
            {
                _bitmap = bitmap.Clone() as Bitmap;
                this.Appearance.Image = bitmap;
            }
        }
Exemple #16
0
        public void ValidateProbabilityLn(double p, int x, double pln)
        {
            var d = new Geometric(p);

            if (x > 0)
            {
                Assert.AreEqual((x - 1) * Math.Log(1.0 - p) + Math.Log(p), d.ProbabilityLn(x));
            }
            else
            {
                Assert.AreEqual(Double.NegativeInfinity, d.ProbabilityLn(x));
            }
        }
Exemple #17
0
        public int SampleDaysInState(double rate)
        {
            // Need to adjust for the fact that only one transition is allowed per day
            // Then we need to convert from a continuous decrement rate to a daily one.
            var pStar = (1 - Math.Exp(-rate)) / Math.Exp(-rate);
            var p     = (1 - Math.Exp(-pStar));

            // This uses the geometric distribution
            // This is the discrete equivalent of a exponential decay model
            var geometricDistribution = new Geometric(p, RandomSource);

            return(geometricDistribution.Sample());
        }
Exemple #18
0
        public void ValidateProbability(double p, int x)
        {
            var d = new Geometric(p);

            if (x > 0)
            {
                Assert.AreEqual <double>(Math.Pow(1.0 - p, x - 1) * p, d.Probability(x));
            }
            else
            {
                Assert.AreEqual <double>(0.0, d.Probability(x));
            }
        }
Exemple #19
0
        public void ValidateProbability([Values(0.0, 0.3, 1.0)] double p, [Values(-1, 0, 1, 2)] int x)
        {
            var d = new Geometric(p);

            if (x > 0)
            {
                Assert.AreEqual(Math.Pow(1.0 - p, x - 1) * p, d.Probability(x));
            }
            else
            {
                Assert.AreEqual(0.0, d.Probability(x));
            }
        }
Exemple #20
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="compositeShape">CompositeShape to copy.</param>
        public CompositeShape(CompositeShape compositeShape) : base(compositeShape)
        {
            Transformer = new CompositeTransformer(this);

            _shapes.InsertedItem += new ShapeCollection.OnInsertedItem(_shapes_InsertedItem);
            _shapes.RemovedItem  += new ShapeCollection.OnRemovedItem(_shapes_RemovedItem);

            Geometric.Reset();

            foreach (IShape shape in compositeShape.Shapes)
            {
                _shapes.Add(shape.Clone() as IShape);
            }
        }
Exemple #21
0
        /// <summary>
        /// Mouse down function.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">MouseEventArgs.</param>
        public override void MouseDown(IDocument document, System.Windows.Forms.MouseEventArgs e)
        {
            _shape = _memoryShape.Clone() as IShape;

            Geometric.Reset();
            Geometric.AddPath(_shape.Geometric, false);

            Visible  = false;
            Selected = false;

            InitializeVersors(_shape.HitTest(e.Location));

            base.MouseDown(document, e);
        }
Exemple #22
0
        /// <summary>
        /// Clones the shape.
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            var img = new Image();

            img.Bitmap   = this.Bitmap.Clone() as Bitmap;
            img.Selected = Selected;
            img.Locked   = Locked;
            img.Geometric.AddRectangle(Geometric.GetBounds());
            img.IsEdited         = IsEdited;
            img.Visible          = Visible;
            img.Appearance.Image = img.Bitmap;
            img.Tag = Tag;
            return(img);
        }
Exemple #23
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="text">Text to view.</param>
        /// <param name="font">Text font.</param>
        /// <param name="stringFormat">String format text.</param>
        public Text(string text, Font font, StringFormat stringFormat)
        {
            if (text != string.Empty)
            {
                _displayedText = text;
            }

            _font         = font;
            _stringFormat = stringFormat;

            Geometric.AddString(text, _font.FontFamily, (int)_font.Style, _font.Size, Geometric.GetBounds(), _stringFormat);

            this.Transformer.RotateOccurred += new RotateHandler(Transformer_RotateOccurred);
        }
Exemple #24
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="start">Start point.</param>
        /// <param name="end">End point.</param>
        public Line(PointF start, PointF end)
        {
            if (start.X == end.X)
            {
                end = new PointF(end.X + 1, end.Y);
            }

            if (start.Y == end.Y)
            {
                end = new PointF(end.X, end.Y + 1);
            }

            Geometric.AddLine(start, end);
            Appearance = new LineAppearance();
        }
Exemple #25
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="text">Text to view.</param>
        /// <param name="font">Text font.</param>
        /// <param name="stringFormat">String format text.</param>
        public Text(string text, Font font, StringFormat stringFormat)
        {
            if (text != string.Empty)
            {
                _displayedText = text;
            }
            this.Locked   = true;
            _font         = font;
            _stringFormat = stringFormat;

            Geometric.AddString(text, _font.FontFamily, (int)_font.Style, _font.Size, Geometric.GetBounds(), _stringFormat);
            //  Geometric.FillMode = System.Drawing.Drawing2D.FillMode.Winding;

            this.Transformer.RotateOccurred += new RotateHandler(Transformer_RotateOccurred);
        }
Exemple #26
0
        static void Main(string[] args)
        {
            List <Vector3> points = new List <Vector3>()
            {
                new Vector3(-8623, 0, -11289),
                new Vector3(11808, 0, -11289),
                new Vector3(11808, 0, 5688),
                new Vector3(-8623, 0, 5688),
                new Vector3(-8623, 0, 5688),
            };

            Vector3 checkP = new Vector3(-5836, 600, 1031);

            Console.WriteLine(Geometric.IsPointInArea(points.ToArray(), checkP));
        }
Exemple #27
0
        public override object Clone()
        {
            var NewBgImage = new BodyBackground();

            if (Bitmap != null)
            {
                // if (Dimension.Width == 1 && Dimension.Height == 1)
                if (Dimension.IsEmpty)
                {
                    NewBgImage.Geometric.AddRectangle(new System.Drawing.Rectangle(0, 0, Bitmap.Width, Bitmap.Height));
                }
                else
                {
                    //  var rec = Geometric.GetBounds();
                    NewBgImage.Geometric.AddRectangle(Geometric.GetBounds());
                }


                // Dimension = new SizeF(bitmap.Width, bitmap.Height);
                NewBgImage.Location = Location;
                NewBgImage.Locked   = Locked;
                NewBgImage.Selected = Selected;
                NewBgImage.Rotation = Rotation;
                NewBgImage.Tag      = Tag;
                NewBgImage.Visible  = Visible;
                // Bitmap.Save("d:\\4545.jpg");

                // اگر دوخط زیر را حذف کنیم هنگام چرخاندن یا ذخیره نمودن تصویر پیغام خطا ظاهر خواهد شد مانند 5 خط پایین تر که سعی می شود در آن تصویر چرخانده شود

                //  Bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
                //Bitmap.RotateFlip(RotateFlipType.Rotate90FlipXY);

                NewBgImage.Bitmap = Bitmap.Clone() as Bitmap;

                try
                {
                    // Bitmap.Save("d:\\4545.jpg");
                    // Bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    //  NewBgImage.Bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
                }
                catch (Exception)
                {
                }

                NewBgImage.Appearance.Image = NewBgImage.Bitmap;
            }
            return(NewBgImage);
        }
Exemple #28
0
        public void ValidateProbabilityLn(
            [Values(0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.3, 1.0, 1.0, 1.0, 1.0)] double p,
            [Values(-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2)] int x,
            [Values(Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -0.35667494393873244235395440410727451457180907089949815, -1.2039728043259360296301803719337238685164245381839102, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, 0.0, Double.NegativeInfinity)] double pln)
        {
            var d = new Geometric(p);

            if (x > 0)
            {
                Assert.AreEqual(((x - 1) * Math.Log(1.0 - p)) + Math.Log(p), d.ProbabilityLn(x));
            }
            else
            {
                Assert.AreEqual(Double.NegativeInfinity, d.ProbabilityLn(x));
            }
        }
Exemple #29
0
        public IActionResult Somar(double width, double height)
        {
            Geometric  myGeometric = new Geometric();
            CaractGeom Resultado   = new CaractGeom();

            Resultado.width   = width;
            Resultado.height  = height;
            Resultado.yI      = Resultado.height / 2;
            Resultado.yS      = Resultado.height / 2;
            Resultado.area    = myGeometric.Area(width, height);
            Resultado.inercia = myGeometric.Inercia(width, height);
            Resultado.wI      = myGeometric.RigFlex(Resultado.inercia, Resultado.yI);
            Resultado.wS      = myGeometric.RigFlex(Resultado.inercia, Resultado.yS);

            return(View("index", Resultado));
        }
    public static void geometric_cdf_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEOMETRIC_CDF_VALUES_TEST tests GEOMETRIC_CDF_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 January 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double cdf = 0;
        double p   = 0;
        int    x   = 0;

        Console.WriteLine("");
        Console.WriteLine("GEOMETRIC_CDF_VALUES_TEST:");
        Console.WriteLine("  GEOMETRIC_CDF_VALUES stores values of");
        Console.WriteLine("  the Geometric Probability Cumulative Density Function.");
        Console.WriteLine("");
        Console.WriteLine("      X      P       CDF");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Geometric.geometric_cdf_values(ref n_data, ref x, ref p, ref cdf);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + x.ToString().PadLeft(6) + "  "
                              + p.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + cdf.ToString("0.################").PadLeft(24) + "");
        }
    }
 public void CanSample()
 {
     var d = new Geometric(0.3);
     d.Sample();
 }
 public void ValidateCumulativeDistribution([Values(0.0, 0.3, 1.0)] double p, [Values(-1, 0, 1, 2)] int x)
 {
     var d = new Geometric(p);
     Assert.AreEqual(1.0 - Math.Pow(1.0 - p, x), d.CumulativeDistribution(x));
 }
 public void ValidateProbabilityLn(double p, int x, double pln)
 {
     var d = new Geometric(p);
     if (x > 0)
     {
         Assert.AreEqual(((x - 1) * Math.Log(1.0 - p)) + Math.Log(p), d.ProbabilityLn(x));
     }
     else
     {
         Assert.AreEqual(Double.NegativeInfinity, d.ProbabilityLn(x));
     }
 }
 public void ValidateToString()
 {
     var d = new Geometric(0.3);
     Assert.AreEqual("Geometric(p = 0.3)", d.ToString());
 }
 public void ValidateMaximum()
 {
     var d = new Geometric(0.3);
     Assert.AreEqual(int.MaxValue, d.Maximum);
 }
 public void ValidateMode(double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual(1, d.Mode);
 }
 public void SetProbabilityOfOneFails(double p)
 {
     var d = new Geometric(0.3);
     d.P = p;
 }
 public void ValidateCumulativeDistribution(double p, int x)
 {
     var d = new Geometric(p);
     Assert.AreEqual(1.0 - Math.Pow(1.0 - p, x), d.CumulativeDistribution(x));
 }
 public void BernoulliCreateFailsWithBadParameters(double p)
 {
     var d = new Geometric(p);
 }
 public void ValidateProbabilityLn(
     [Values(0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 0.3, 1.0, 1.0, 1.0, 1.0)] double p, 
     [Values(-1, 0, 1, 2, -1, 0, 1, 2, -1, 0, 1, 2)] int x, 
     [Values(Double.NegativeInfinity, 0.0, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -0.35667494393873244235395440410727451457180907089949815, -1.2039728043259360296301803719337238685164245381839102, Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, 0.0, Double.NegativeInfinity)] double pln)
 {
     var d = new Geometric(p);
     if (x > 0)
     {
         Assert.AreEqual(((x - 1) * Math.Log(1.0 - p)) + Math.Log(p), d.ProbabilityLn(x));
     }
     else
     {
         Assert.AreEqual(Double.NegativeInfinity, d.ProbabilityLn(x));
     }
 }
 public void ValidateProbability([Values(0.0, 0.3, 1.0)] double p, [Values(-1, 0, 1, 2)] int x)
 {
     var d = new Geometric(p);
     if (x > 0)
     {
         Assert.AreEqual(Math.Pow(1.0 - p, x - 1) * p, d.Probability(x));
     }
     else
     {
         Assert.AreEqual(0.0, d.Probability(x));
     }
 }
 public void ValidateMedian([Values(0.0, 0.3, 1.0)] double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual((int)Math.Ceiling(-Math.Log(2.0) / Math.Log(1 - p)), d.Median);
 }
 public void ValidateMode([Values(0.0, 0.3, 1.0)] double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual(1, d.Mode);
 }
 public void CanSetProbabilityOfOne(double p)
 {
     var d = new Geometric(0.3);
     d.P = p;
 }
 public void CanCreateGeometric([Values(0.0, 0.3, 1.0)] double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual(p, d.P);
 }
 public void SetProbabilityOfOneFails(double p)
 {
     var d = new Geometric(0.3);
     Assert.That(() => d.P = p, Throws.ArgumentException);
 }
 public void ValidateToString()
 {
     var d = new Geometric(0.3);
     Assert.AreEqual(String.Format("Geometric(P = {0})", d.P), d.ToString());
 }
 public void ValidateEntropy(double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual(((-p * Math.Log(p, 2.0)) - ((1.0 - p) * Math.Log(1.0 - p, 2.0))) / p, d.Entropy);
 }
 public void SetProbabilityOfOneFails([Values(Double.NaN, -1.0, 2.0)] double p)
 {
     var d = new Geometric(0.3);
     Assert.Throws<ArgumentOutOfRangeException>(() => d.P = p);
 }
 public void ValidateMinimum()
 {
     var d = new Geometric(0.3);
     Assert.AreEqual(1.0, d.Minimum);
 }
 public void SetProbabilityOfOneFails(double p)
 {
     var d = new Geometric(0.3);
     Assert.Throws<ArgumentOutOfRangeException>(() => d.P = p);
 }
 public void ValidateProbability(double p, int x)
 {
     var d = new Geometric(p);
     if (x > 0)
     {
         Assert.AreEqual(Math.Pow(1.0 - p, x - 1) * p, d.Probability(x));
     }
     else
     {
         Assert.AreEqual(0.0, d.Probability(x));
     }
 }
 public void ValidateEntropy(double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual<double>((-p * System.Math.Log(p, 2.0) - (1.0 - p) * System.Math.Log(1.0 - p, 2.0)) / p, d.Entropy);
 }
 public void ValidateSkewness(double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual((2.0 - p) / Math.Sqrt(1.0 - p), d.Skewness);
 }
 public void ValidateMaximum()
 {
     var d = new Geometric(0.3);
     int max = d.Maximum;
 }
 public void CanCreateGeometric(double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual(p, d.P);
 }
 public void ValidateMedian(double p)
 {
     var d = new Geometric(p);
     Assert.AreEqual<double>((int)Math.Ceiling(-Math.Log(2.0) / System.Math.Log(1 - p)), d.Median);
 }
 public void CanSampleSequence()
 {
     var d = new Geometric(0.3);
     var ied = d.Samples();
     ied.Take(5).ToArray();
 }
 public void ValidateSkewness()
 {
     var d = new Geometric(0.3);
     double s = d.Skewness;
 }