Geometry

Reputation Top 1%

Geometry

1074 Snippets
(2nd place)

Published

4 Channels

Created

1 Channel

Following

Jan 19, 2017

Last Visit

Jul 28, 2016

Registered

22471 points (2nd place)

Reputation

**Top 1% Publisher**

Junior Code Generator

Serious Code Generator

Senior Code Generator

Master Code Generator

Guru Code Generator

Junior Publisher

Guru Publisher

Junior Topic Creator

Junior Topic Hub

Serious Topic Hub

Junior Trend Maker

Master Trend Maker

Guru Trend Maker

Junior Autobiographer

Serious Autobiographer

## Recent Snippets See all snippets by Geometry

####
public
by Geometry created **Sep 26, 2016**
*79*
*2*
*3*
*0*

### Random: Returns a random symbol within the given symbol probabilities.

Returns a random symbol within the given symbol probabilities.
The probabilities for the discrete symbols.
A random symbol within the given probabilities.

/// <summary> /// Returns a random symbol within the given symbol probabilities. /// </summary> /// /// <param name="probabilities">The probabilities for the discrete symbols.</param> /// /// <returns>A random symbol within the given probabilities.</returns> /// public static int Random(double[] probabilities) { double uniform = Accord.Math.Random.Generator.Random.NextDouble(); double cumulativeSum = 0; // Use the probabilities to partition the [0,1] interval // and check inside which range the values fall into. for (int i = 0; i < probabilities.Length; i++) { cumulativeSum += probabilities[i]; if (uniform < cumulativeSum) return i; } throw new InvalidOperationException("Generated value is not between 0 and 1."); }

####
public
by Geometry created **Sep 26, 2016**
*69*
*2*
*3*
*0*

### Uniform: Constructs a new uniform discrete distribution.

Constructs a new uniform discrete distribution.
The integer value where the distribution starts, also
known as a. Default value is 0.
The integer value where the distribution ends, also
known as b.

/// <summary> /// Constructs a new uniform discrete distribution. /// </summary> /// /// <param name="a"> /// The integer value where the distribution starts, also /// known as <c>a</c>. Default value is 0.</param> /// <param name="b"> /// The integer value where the distribution ends, also /// known as <c>b</c>.</param> /// public static GeneralDiscreteDistribution Uniform(int a, int b) { if (a > b) { throw new ArgumentOutOfRangeException("b", "The starting number a must be lower than b."); } return new GeneralDiscreteDistribution(a, b - a + 1); }

####
public
by Geometry created **Sep 26, 2016**
*66*
*2*
*3*
*0*

### WMinimum: Computes the Wilcoxon's W statistic.

Computes the Wilcoxon's W statistic.
The W statistic is computed as the
minimum of the W+ and W- statistics.

/// <summary> /// Computes the Wilcoxon's W statistic. /// </summary> /// /// <remarks> /// The W statistic is computed as the /// minimum of the W+ and W- statistics. /// </remarks> /// public static double WMinimum(int[] signs, double[] ranks) { double wp = 0, wn = 0; for (int i = 0; i < signs.Length; i++) { if (signs[i] < 0) wn += ranks[i]; else if (signs[i] > 0) wp += ranks[i]; } double min = Math.Min(wp, wn); return min; }

####
public
by Geometry created **Sep 26, 2016**
*48*
*1*
*3*
*0*

### WNegative: Computes the Wilcoxon's W- statistic.

Computes the Wilcoxon's W- statistic.
The W- statistic is computed as the
sum of all negative signed ranks.

/// <summary> /// Computes the Wilcoxon's W- statistic. /// </summary> /// /// <remarks> /// The W- statistic is computed as the /// sum of all negative signed ranks. /// </remarks> /// public static double WNegative(int[] signs, double[] ranks) { double sum = 0; for (int i = 0; i < signs.Length; i++) if (signs[i] < 0) sum += ranks[i]; return sum; }

####
public
by Geometry created **Sep 26, 2016**
*49*
*1*
*3*
*0*

### WPositive: Computes the Wilcoxon's W+ statistic.

Computes the Wilcoxon's W+ statistic.
The W+ statistic is computed as the
sum of all positive signed ranks.

/// <summary> /// Computes the Wilcoxon's W+ statistic. /// </summary> /// /// <remarks> /// The W+ statistic is computed as the /// sum of all positive signed ranks. /// </remarks> /// public static double WPositive(int[] signs, double[] ranks) { double sum = 0; for (int i = 0; i < signs.Length; i++) if (signs[i] > 0) sum += ranks[i]; return sum; }