Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
GH-37: Moving the Dissimilarity class inside the Math project; improv…
Browse files Browse the repository at this point in the history
…ing documentation.
  • Loading branch information
cesarsouza committed Oct 13, 2014
1 parent faca748 commit b52773c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 27 deletions.
1 change: 1 addition & 0 deletions Sources/Accord.Math/Accord.Math.csproj
Expand Up @@ -120,6 +120,7 @@
<Compile Include="Convergence\Base\IConvergence.cs" />
<Compile Include="Convergence\GeneralConvergence.cs" />
<Compile Include="Decompositions\Accord.Math.Decompositions.cs" />
<Compile Include="Dissimilarity.cs" />
<Compile Include="Functions\OwensT.cs" />
<Compile Include="Integration\Accord.Math.Integration.cs" />
<Compile Include="Integration\Base\IMultidimensionalIntegration.cs" />
Expand Down
@@ -1,24 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Accord.Statistics
// Accord Math Library
// The Accord.NET Framework
// http://accord-framework.net
//
// Copyright © Diego Catalano, 2014
// diego.catalano at live.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//

namespace Accord.Math
{

/// <summary>
/// Static class Dissimilarity. Defines a set of extension methods defining dissimilarity measures.
/// Static class Dissimilarity. Provides extension methods defining dissimilarity measures.
/// </summary>
///
public static class Dissimilarity
{
/// <summary>
/// Gets the Dice dissimilarity between two vectors.
/// Computes the Dice dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Dice dissimilarity between x and y.</returns>
///
public static double Dice(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -34,14 +55,16 @@ public static double Dice(int[] x, int[] y)
}

/// <summary>
/// Gets the Jaccard dissimilarity between two vectors.
/// Computes the Jaccard dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Jaccard dissimilarity between x and y.</returns>
///
public static double Jaccard(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -57,14 +80,16 @@ public static double Jaccard(int[] x, int[] y)
}

/// <summary>
/// Gets the Kulsinsk dissimilarity between two vectors.
/// Computes the Kulsinsk dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Kulsinsk dissimilarity between x and y.</returns>
///
public static double Kulsinsk(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -80,14 +105,16 @@ public static double Kulsinsk(int[] x, int[] y)
}

/// <summary>
/// Gets the Matching dissimilarity between two vectors.
/// Computes the Matching dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Matching dissimilarity between x and y.</returns>
///
public static double Matching(int[] x, int[] y)
{

int tf = 0;
int ft = 0;

Expand All @@ -101,14 +128,16 @@ public static double Matching(int[] x, int[] y)
}

/// <summary>
/// Gets the Rogers Tanimoto dissimilarity between two vectors.
/// Computes the Rogers-Tanimoto dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Rogers Tanimoto dissimilarity between x and y.</returns>
///
public static double RogersTanimoto(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -127,14 +156,16 @@ public static double RogersTanimoto(int[] x, int[] y)
}

/// <summary>
/// Gets the Russel Rao dissimilarity between two vectors.
/// Computes the Russel Rao dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Russel Rao dissimilarity between x and y.</returns>
///
public static double RusselRao(int[] x, int[] y)
{

int tt = 0;

for (int i = 0; i < x.Length; i++)
Expand All @@ -146,14 +177,16 @@ public static double RusselRao(int[] x, int[] y)
}

/// <summary>
/// Gets the Sokal Michener dissimilarity between two vectors.
/// Computes the Sokal-Michener dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
/// <returns>The Sokal Michener dissimilarity between x and y.</returns>
///
/// <returns>The Sokal-Michener dissimilarity between x and y.</returns>
///
public static double SokalMichener(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -172,14 +205,16 @@ public static double SokalMichener(int[] x, int[] y)
}

/// <summary>
/// Gets the Sokal Sneath dissimilarity between two vectors.
/// Computes the Sokal Sneath dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Sokal Sneath dissimilarity between x and y.</returns>
///
public static double SokalSneath(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -196,14 +231,16 @@ public static double SokalSneath(int[] x, int[] y)
}

/// <summary>
/// Gets the Yule dissimilarity between two vectors.
/// Computes the Yule dissimilarity between two vectors.
/// </summary>
///
/// <param name="x">A vector.</param>
/// <param name="y">A vector.</param>
///
/// <returns>The Yule dissimilarity between x and y.</returns>
///
public static double Yule(int[] x, int[] y)
{

int tf = 0;
int ft = 0;
int tt = 0;
Expand All @@ -220,5 +257,6 @@ public static double Yule(int[] x, int[] y)
double r = 2 * (tf + ft);
return r / (tt + ff + r / 2);
}

}
}
1 change: 0 additions & 1 deletion Sources/Accord.Statistics/Accord.Statistics.csproj
Expand Up @@ -152,7 +152,6 @@
<Compile Include="Analysis\Performance\ReceiverOperatingCharacteristic.cs" />
<Compile Include="Analysis\StepwiseLogisticRegressionAnalysis.cs" />
<Compile Include="Circular.cs" />
<Compile Include="Dissimilarity.cs" />
<Compile Include="Distributions\Accord.Statistics.Distributions.cs" />
<Compile Include="Distributions\Density Kernels\Accord.Statistics.Distributions.DensityKernels.cs" />
<Compile Include="Distributions\Density Kernels\IDensityKernel.cs" />
Expand Down

0 comments on commit b52773c

Please sign in to comment.