English 中文(简体)
C#的多方面关联
原标题:multiple dimension correlation in c#

参照两个N-dimensional系列的点数,每个长度为M.,目的是对点数进行校正,计算相关系数。

意欲理解的是,如何调整算法,以核算所有N方面,而不是仅仅说明问题。

series A = [0, 0] [1, 1] [2, 2] [3, 3]  
series B = [0,  0] [1, -1] [2, -2] [3, -3]

如果我们只利用第一个方面来进行相互关系,我们就会获得+1.00。 如果我们使用第二种方法,我们就得1.00.,但我们可以看到,如果我们考虑相互关系的两个方面,答案就算是1.00或1.00。

因此,大麻知道如何形成这种多维的相互关系,最好是在c#中。

感到可以自由要求进一步澄清或ed忙进一步改进员额。

EDIT:使用系列成像是储存时间序列。 i 检索最新的海法中心价格样本,作为系列A,开始将其与所有历史数据联系起来(数据1.1至数据[M+1]、数据1.2至数据[M+1]、数据[1000]至[M+1000]等)。 i 想确定一些指标相似的区域,例如CLLOSE、VOLUME等,因此,时间序列对每个指数只具有一个价值,但具有一整套价值。

如果在相关方面只使用CLCS,那么,如果这些系列的VOLUME序列也相似,则可以保证,如果使用VOLUME,那么,如果这些系列中的CLOSE顺序也相似,则需要一种基于某种距离尺度的正常关联。 比如^2 + b^2. 如果CLCS的数值相似,^2将很小,如果VOLUME的数值相似,b^2将很小,如果^2 + b^2的数值很小,就意味着CLCS和VOLUME也相似。

previously what i was doing was as follows:
1. use CLOSE prices to calculate correlation.
2. use VOLUME to calculate correlation.
3. multiply these values together.. this will ensure that high correlation values will imply that both CLOSE and VOLUME have strong individual correlations..

EDIT:

stdDevX = Sqrt (Summation ((x - Mean(x)) * (x - Mean(x)) / N)
stdDevY = Sqrt (Summation ((y - Mean(y)) * (y - Mean(y)) / N)  
corrXY = Summation ((x - Mean(x) * (y - Mean(y)) / (stdDevX * stdDevY)) / (N - 1)  

http://en.wikipedia.org/wiki/Standard_deviation
http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient

the above formulae assume that both series x and y are one-dimensional.. my main concern is how to adapt these formulae for multi-dimensional vectors.. i wish to use it to find regions where all price metrics are similar in history.. but it can be used by anyone who wishes to correlate any sort of vertors.. x,y,z coordinates of an object, etc..

最佳回答

这个问题并不明确,但我认为,正在要求你分别处理每一系列。 ∗∗∗∗∗ 丛书 作为X和Y两个变量的表层的一组样本,这两个变量被完全捆绑(如果你绘制了目录,所有数值都将直线从底线向上线),因此相关数字是+1。

In contrast, considering just Series B as another sequence of samples from X and Y, this time a scatter plot would again be a straight line from top-left to bottom right. Increasing X decreases Y. The correlation is -1.

如果每个系列都包含三个变量的样本(例如,一段时间以来三个库存价格的缩略),就会更加令人感兴趣。 这是一个简单的例子:

            X  Y  Z   X  Y   Z   X  Y   Z   X  Y   Z
series C = [0, 0, 0] [1, 1, -1] [2, 2, -2] [3, 3, -3]

在此,您需要考虑变量的each pair之间的相互关系。 在这种简单的情况下,XY之间的相互关系为+1,在XZ之间为-1,在YZ之间为-1。

Edit: Combining correlations

附录中包含三个变量——closehighlow——的样本,期限为两年,并想知道这两个时期是否好。 你们可以以传统方式计算每个变数的两个时间段之间的相互关系。 Suppose this productions close-correlation = 0.6, high-correlation = 0.3, and low-correlation = 0.4。

你们需要采用某种方法,将个人关联与适当分数合在一起,这样,个人关系远非零(即高度关联,无论是积极的还是消极的),对分数的贡献比接近零。 简单做法包括:将产品(0.6* 0.3 * 0.4 = 0.072)或根基-地基(sqrt(0.6^2 + 0.3^2 + 0.4^2)/ 3)计算为0.409。

问题回答
int GetCorrelationScore(Array[,] seriesA, Array[,] seriesB)
{
   int correlationScore = 0;

   for (var i = 0, i < seriesA.Length; i++)
   {
      if (areEqual(seriesA[i][0], seriasB[i][0], 0.5m) && areEqual(seriesA[i][1], seriasB[i][1], 0.5m))
         correlationScore++;
      else
         correlationScore--;
   }
}

bool areEqual(decimal value1, decimal value2, decimal allowedVariance)
{
   var lowValue1 = value1 - allowedVariance;
   var highValue1 = value1 + allowedVariance;

   return (lowValue1 < value2 && highValue1 > value2)
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签