Show / Hide Table of Contents

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
System.Object
DiscreteConverter<T>
Implements
Troschuetz.Random.IDiscreteDistribution
Troschuetz.Random.IDistribution
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

DiscreteConverter(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 Source

CanReset

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
| Improve this Doc View Source

ContinuousDistribution

The continuous distribution being wrapped.

Declaration
public T ContinuousDistribution { get; }
Property Value
Type Description
T
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

Mean

Gets the mean of distributed random numbers for the underlying distribution.

Declaration
public double Mean { get; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

Median

Gets the median of distributed random numbers for the underlying distribution.

Declaration
public double Median { get; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

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
| Improve this Doc View Source

Mode

Gets the mode of distributed random numbers.

Declaration
public double[] Mode { get; }
Property Value
Type Description
System.Double[]
| Improve this Doc View Source

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 Source

Next()

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

Implements

Troschuetz.Random.IDiscreteDistribution
Troschuetz.Random.IDistribution

Extension Methods

Utility.Yield<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX