/// <summary>Creates an approximate simulation of a distribution</summary>
    /// <param name="curve">The mathematical function of the distribution(between min and max)</param>
    /// <param name="min">The minimum possible value in this distribution</param>
    /// <param name="max">The maximum possible value in this distribution</param>
    /// <param name="precision">Increasing this will improve the accuracy of the generator at the cost of speed</param>
    public Distribution(DistributionCurve curve, float min, float max, int precision)
    {
#if DEBUG
        // Input checks:
        if (precision < 1)
        {
            Debug.LogError("Distribution constructor called with invalid precision: " + precision);
            Debug.Break();
        }
#endif
        // Define the left starting point and the width of the bars in the bar graph.
        this.min      = min;
        this.barWidth = (max - min) / precision;

        // Precalculate a bar graph that will represent the distribution.
        barHeights     = new float[precision];
        totalBarHeight = 0;
        for (int i = 0; i < precision; i++)
        {
            // Find the input point at the middle of this bar on the graph.
            float middle = (i + 0.5f) * barWidth;
            // Use the distribution curve to get the height of the bar.
            barHeights[i]   = curve(middle);
            totalBarHeight += barHeights[i];
        }
    }
 /// <summary>Creates an approximate simulation of a distribution</summary>
 /// <param name="curve">The mathematical function of the distribution(between min and max)</param>
 /// <param name="min">The minimum possible value in this distribution</param>
 /// <param name="max">The maximum possible value in this distribution</param>
 public Distribution(DistributionCurve curve, float min, float max)
     : this(curve, min, max, defaultPrecision)
 {
 }
 /// <summary>Creates an approximate simulation of a distribution between 0 and 1</summary>
 /// <param name="curve">The mathematical function of the distribution(between 0 and 1)</param>
 public Distribution(DistributionCurve curve)
     : this(curve, 0, 1)
 {
 }