Class DiscreteConverter<T>
Wraps a continuous distribution and allows it to be used as discrete, by rounding double values produced by NextDouble() to the nearest int. Its minimum, maximum, mean, median, variance, and mode(s) are exactly the same as its underlying Troschuetz.Random.IContinuousDistribution.
Inheritance
Implements
Inherited Members
Namespace: GoRogue.Random
Assembly: GoRogue.dll
Syntax
public class DiscreteConverter<T> : IDiscreteDistribution, IDistribution where T : IContinuousDistribution
Type Parameters
Name | Description |
---|---|
T | The type of continuous distribution being wrapped. Must implement Troschuetz.Random.IContinuousDistribution. |
Remarks
Takes a value of type T so that its ContinuousDistribution can return a value of the exact wrapped type, which still enables access to any distribution-specified fields, etc.
Constructors
| Improve this Doc View SourceDiscreteConverter(T)
Constructor. Takes the continuous distribution to wrap.
Declaration
public DiscreteConverter(T continuousDistribution)
Parameters
Type | Name | Description |
---|---|---|
T | continuousDistribution | Continuous distribution instance to wrap around. |
Properties
| Improve this Doc View SourceCanReset
Gets a value indicating whether the underlying random number distribution can be reset, so that it produces the same random number sequence again.
Declaration
public bool CanReset { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ContinuousDistribution
The continuous distribution being wrapped.
Declaration
public T ContinuousDistribution { get; }
Property Value
Type | Description |
---|---|
T |
Generator
Gets the Troschuetz.Random.IGenerator object that is used as underlying random number generator.
Declaration
public IGenerator Generator { get; }
Property Value
Type | Description |
---|---|
Troschuetz.Random.IGenerator |
Maximum
Gets the maximum possible value of distributed random numbers for the underlying distribution.
Declaration
public double Maximum { get; }
Property Value
Type | Description |
---|---|
System.Double |
Mean
Gets the mean of distributed random numbers for the underlying distribution.
Declaration
public double Mean { get; }
Property Value
Type | Description |
---|---|
System.Double |
Median
Gets the median of distributed random numbers for the underlying distribution.
Declaration
public double Median { get; }
Property Value
Type | Description |
---|---|
System.Double |
Minimum
Gets the minimum possible value of distributed random numbers for the underlying distribution.
Declaration
public double Minimum { get; }
Property Value
Type | Description |
---|---|
System.Double |
Mode
Gets the mode of distributed random numbers.
Declaration
public double[] Mode { get; }
Property Value
Type | Description |
---|---|
System.Double[] |
Variance
Gets the variance of distributed random numbers for the underlying distribution.
Declaration
public double Variance { get; }
Property Value
Type | Description |
---|---|
System.Double |
Methods
| Improve this Doc View SourceNext()
Returns the result of the underlying continuous distribution's NextDouble() function, but rounded to the nearest integer.
Declaration
public int Next()
Returns
Type | Description |
---|---|
System.Int32 | The result of the underlying continuous distribution's NextDouble() function, rounded to the nearest integer. |
NextDouble()
Returns a distributed floating point random number from the underlying continuous generator.
Declaration
public double NextDouble()
Returns
Type | Description |
---|---|
System.Double | A distributed double-precision floating point number. |
Reset()
Resets the random number distribution, so that it produces the same random number sequence again.
Declaration
public bool Reset()
Returns
Type | Description |
---|---|
System.Boolean | true if the random number distribution was reset; otherwise, false. |