System.Random.Sample C# (CSharp) Method

Sample() protected method

protected Sample ( ) : double
return double
      protected virtual double Sample() {
          //Including this division at the end gives us significantly improved
          //random number distribution.
          return (InternalSample()*(1.0/MBIG));
      }
    

Usage Example

示例#1
0
文件: Cellular.cs 项目: dzamkov/DUIP
        /// <summary>
        /// Creates a grid-like distribution of points.
        /// </summary>
        /// <param name="Size">The edge-length of the grid.</param>
        /// <param name="Error">The amount each grid point is moved relative to the space between grid points.</param>
        /// <param name="Probability">The probability that a certain grid point will be used.</param>
        public static IEnumerable<Point> GridDistribution(Random Random, int Size, double Error, double Probability)
        {
            double delta = 1.0 / Size;
            Error *= delta;

            double off = delta * 0.5 - Error * 0.5;
            for (int x = 0; x < Size; x++)
            {
                for (int y = 0; y < Size; y++)
                {
                    if (Random.Sample() < Probability)
                    {
                        Point p = new Point(x * delta, y * delta);
                        p.X += off + Random.Sample() * Error;
                        p.Y += off + Random.Sample() * Error;
                        yield return p;
                    }
                }
            }
        }
All Usage Examples Of System.Random::Sample