精华内容
下载资源
问答
  • MATLAB互相关系数

    千次阅读 2019-05-02 18:12:45
    MATLAB的使用 需要测量天津大爆炸的地震波形,小白不懂的怎么用MATLAB啊,真的是从来都没有接触过,求路过大神帮个忙,需要写一个关于计算互相关系数的程序,真的着急 提前谢过了!! ...

    MATLAB的使用

    需要测量天津大爆炸的地震波形,小白不懂的怎么用MATLAB啊,真的是从来都没有接触过,求路过大神帮个忙,需要写一个关于计算互相关系数的程序,真的着急 提前谢过了!!

    展开全文
  • 两序列皮尔逊互相关系数计算

    千次阅读 2019-01-27 10:52:21
    在信号去噪处理中,通常可以使用 信噪比、均方根误差、互相关系数 来评估去噪信号与原始信号的相似程度。  互相关系数计算公式:    matlab代码实现: %////////////////////////// 方法一 /////////////////...

    在信号去噪处理中,通常可以使用    信噪比、均方根误差、互相关系数    来评估去噪信号与原始信号的相似程度。

         互相关系数计算公式:

                                            

        matlab代码实现

    %//   方法一  

          t=0:0.01:10;
          x=sin(t);
          y=sin(t)+randn(1,length(t))*0.3;
          a=corr(x',y','type','Pearson')        %注意:x和y均为列序列,得出的结果才是一个系数,否则输出一个矩阵

          输出结果:

                      a = 0.9146

    %%/   方法二   /

               t=0:0.01:10;
               x=sin(t);
               y=sin(t)+randn(1,length(t))*0.5;
               corr2(x,y)   % 行序列或列序列都行

    %%

     

           均方根误差计算公式:

                                               

     

             信噪比计算公式:

                                            

     

     

     

    展开全文
  • %求y相对于x的互相关系数,横轴为-5时对应相关系数最大为3.32,表示y滞后x5阶 %[c,lags] = xcorr(x,y); %归一化相关系数,即使零滞后时的自相关等于1,并指定所求最大领先(滞后)阶数为10 [c,lags] = xcorr(x,y,10,'...

    计算皮尔逊相关系数——corr

    %% 多变量间相关性分析和选取相关性强的变量方法属于“属性约减”范畴。
    %即进行各变量间的相关性分析,选取相关性强的变量。
    %可以使用皮尔逊Pearson相关性系数r进行衡量,如果其绝对值越接近1,则变量X,Y的相关性越强。
    %对相关性系数进行排序,保留相关性强的变量,剔除相关性差的变量。
    % 一般来说,取绝对值后,0-0.09为没有相关性,0.3-弱,0.1-0.3为弱相关,0.3-0.5为中等相关,0.5-1.0为强相关。
    %但是,往往你还需要做显著性差异检验,即t-test,来检验两组数据是否显著相关,这在SPSS里面会自动计算的
    %%
    ys_data=xlsread('季度数据.xlsx');  %读入原始数据,第一列放因变量
    [n,p]=size(ys_data);             % n行,p列
    n=18;p=20;%直接指定
    for i=2:p
        Y=ys_data(:,1);                     % 将因变量赋值给Y
        X=ys_data(:,i);                     % 逐个将自变量赋值给X
        xs(1,i-1)=i;                           % 将相关性系数数组的第一行添加变量所在列位置标记1:p
        xs(2,i-1)=corr(X,Y,'type','Pearson');  %逐个计算自变量与因变量间的Pearson相关性,保存至xs数组第二行
    end
    xyb=[ys_data;[1 xs(2,:)]];
    
    xlswrite('季度数据pearson.xlsx',xyb); 
    

    计算互相关系数——xcorr

    %% 互相关分析(cross correlation)是利用互相关系
    %数来估计整个时间序列中两个序列之间相关程度%的一种标准方法。
    %其原理在于将被选指标相对于基%准指标前后移动若干个时间单位,
    %然后对移动后的序列和基准指标序列求相关系数,最大的相关系数
    %所对应的移动时间就是该指标领先或延迟的时间段
    
    %%
    n = 0:15;
    x = 0.84.^n;
    y = circshift(x,5);%x向右移动5个元素生成y,即y滞后x5阶
    %求y相对于x的互相关系数,横轴为-5时对应相关系数最大为3.32,表示y滞后x5阶
    %[c,lags] = xcorr(x,y);
    %归一化相关系数,即使零滞后时的自相关等于1,并指定所求最大领先(滞后)阶数为10
    [c,lags] = xcorr(x,y,10,'coeff');
    stem(lags,c)
    

    在这里插入图片描述

    %%
    %计算并绘制向量 x 的估计自相关。
    %在零滞后时(此时 x 与自身完全匹配),出现最大峰值。
    n = 0:15;
    x = 0.84.^n;
    [c,lags] = xcorr(x);
    figure(2)
    stem(lags,c)
    

    在这里插入图片描述

    展开全文
  • Cross Correlation AutoCorrelation -- 2D Pattern Identification Written by Paul Bourke August 1996 Cross correlation is a standard method of estimating the degree to which two series are

    Cross Correlation

    AutoCorrelation -- 2D Pattern Identification

    Written by Paul Bourke
    August 1996


    Cross correlation is a standard method of estimating the degree to which two series are correlated. Consider two series x(i) and y(i) where i=0,1,2...N-1. The cross correlation r at delay d is defined as

    Where mx and my are the means of the corresponding series. If the above is computed for all delays d=0,1,2,...N-1 then it results in a cross correlation series of twice the length as the original series.

    There is the issue of what to do when the index into the series is less than 0 or greater than or equal to the number of points. (i-d < 0 or i-d >= N) The most common approaches are to either ignore these points or assuming the series x and y are zero for i < 0 and i >= N. In many signal processing applications the series is assumed to be circular in which case the out of range indexes are "wrapped" back within range, ie: x(-1) = x(N-1), x(N+5) = x(5) etc

    The range of delays d and thus the length of the cross correlation series can be less than N, for example the aim may be to test correlation at short delays only. The denominator in the expression above serves to normalise the correlation coefficients such that -1 <= r(d) <= 1, the bounds indicating maximum correlation and 0 indicating no correlation. A high negative correlation indicates a high correlation but of the inverse of one of the series.


    As a simple example consider the two rectangular pulses shown below in blue and green, the correlation series is shown in red.

    The maximum correlation is achieved at a delay of 3. Considering the equations above, what is happening is the second series is being slid past the first, at each shift the sum of the product of the newly lined up terms in the series is computed. This sum will be large when the shift (delay) is such that similar structure lines up. This is essentially the same as the so called convolution except for the normalisation terms in the denominator.

    Source code

    Sample C source to calculate the correlation series with no data wrapping. The two series are x[], and y[] of "n" points. The correlation series is calculated for a maximum delay of "maxdelay".

       int i,j
       double mx,my,sx,sy,sxy,denom,r;
       
       /* Calculate the mean of the two series x[], y[] */
       mx = 0;
       my = 0;   
       for (i=0;i<n;i++) {
          mx += x[i];
          my += y[i];
       }
       mx /= n;
       my /= n;
    
       /* Calculate the denominator */
       sx = 0;
       sy = 0;
       for (i=0;i<n;i++) {
          sx += (x[i] - mx) * (x[i] - mx);
          sy += (y[i] - my) * (y[i] - my);
       }
       denom = sqrt(sx*sy);
    
       /* Calculate the correlation series */
       for (delay=-maxdelay;delay<maxdelay;delay++) {
          sxy = 0;
          for (i=0;i<n;i++) {
             j = i + delay;
             if (j < 0 || j >= n)
                continue;
             else
                sxy += (x[i] - mx) * (y[j] - my);
             /* Or should it be (?)
             if (j < 0 || j >= n)
                sxy += (x[i] - mx) * (-my);
             else
                sxy += (x[i] - mx) * (y[j] - my);
             */
          }
          r = sxy / denom;
          
          /* r is the correlation coefficient at "delay" */
    
       }

    If the series are considered circular then the source with the same declarations as above might be

       /* Calculate the mean of the two series x[], y[] */
       mx = 0;
       my = 0;   
       for (i=0;i<n;i++) {
          mx += x[i];
          my += y[i];
       }
       mx /= n;
       my /= n;
    
       /* Calculate the denominator */
       sx = 0;
       sy = 0;
       for (i=0;i<n;i++) {
          sx += (x[i] - mx) * (x[i] - mx);
          sy += (y[i] - my) * (y[i] - my);
       }
       denom = sqrt(sx*sy);
    
       /* Calculate the correlation series */
       for (delay=-maxdelay;delay<maxdelay;delay++) {
          sxy = 0;
          for (i=0;i<n;i++) {
             j = i + delay;
             while (j < 0)
                j += n;
             j %= n;
             sxy += (x[i] - mx) * (y[j] - my);
          }
          r = sxy / denom;
          
          /* r is the correlation coefficient at "delay" */
    
       }
    Example

    The following shows two time series x,y.

    The cross correlation series with a maximum delay of 4000 is shown below. There is a strong correlation at a delay of about 40.

    Auto Correlation

    When the correlation is calculated between a series and a lagged version of itself it is called autocorrelation. A high correlation is likely to indicate a periodicity in the signal of the corresponding time duration. 
    The correlation coefficient at lag k of a series x0, x1, x2,....xN-1 is normally given as

    Where mx is the mean of the series. When the term i+k extends past the length of the series N two options are available. The series can either be considered to be 0 or in the usual Fourier approach the series is assumed to wrap, in this case the index into the series is (i+k) mod N.

    If the correlation coefficient is calculated for all lags k=0,1,2...N-1 the resulting series is called the autocorrelation series or the correlogram. The autocorrelation series can be computed directly as above or from the Fourier transform as

    That is, one can compute the autocorrelation series by transforming the series into the frequency domain, taking the modulus of each spectral coefficient, and then performing the inverse transform. Note that depending on the normalisation used with the particular FFT algorithm there may need to be a scaling by N.

    This method for computing the auto correlation series is particularly useful for long series where the efficiency of the Fast Fourier Transform can significantly reduce the time required to compute the autocorrelation series.

    Note that this is a special case of the expression for calculating the cross correlation using Fourier transforms. The Fourier transform of the cross correlation function is the product of the Fourier transform of the first series and the complex conjugate of the Fourier transform of the second series.

    2D Pattern Identification using Cross Correlation

    One approach to identifying a pattern within an image uses cross correlation of the image with a suitable mask. Where the mask and the pattern being sought are similar the cross correlation will be high. The mask is itself an image which needs to have the same functional appearance as the pattern to be found.

    Consider the image below in black and the mask shown in red. The mask is centered at every pixel in the image and the cross correlation calculated, this forms a 2D array of correlation coefficients.

    The form of the un-normalised correlation coefficient at position (i,j) on the image is given by

    where  is the mean of the masks pixels and  is the mean of the image pixels under (covered by) the mask.

    The peaks in this cross correlation "surface" are the positions of the best matches in the image of the mask.

    Issues
    • The process can be extremely time consuming, the 2D cross correlation function needs to be computed for every point in the image. Calculation of the cross correlation function is itself a N2 operation. Ideally the mask should be chosen as small as practicable.

    • In many image identification processes the mask may need to be rotated and/or scaled at each position.

    • This process is very similar to 2D filtering except in that case the image is replaced by an appropriately scaled version of the correlation surface.

    Example 1
    In this first example it was necessary to pick out the position of the colour singularities and to determine the orientation of the colour sequence. A sample image illustrating the singularities to be analysed is shown below (all images and masks shown here are at the same scale)




    Two masks were required as the colour circles exist as mirror images as well as rotated. That is, yellow on the right of read and yellow on the left of red.

     

     

    The maximum cross correlation for all angles and for each of the two masks is retained for each position. This maximum cross correlation surface with the image mapped onto it is

    Example 2
    This example is basically the same as the previous one except the non singularity regions haven't been pre-filtered.

                                                                                                                     


    The resulting surface where the height is proportional to the maximum correlation coefficient across all angles and for the mirror of the masks is

    The width and relative height of the correlation peaks can be improved by matching the dimensions of the mask with those of the features being sought in the image. For example, if the size of the mask is smaller and radial as below

     (Note: the black denotes no mask is applied, not the colour black)

    then the peaks are significantly narrower.

    The above is an example over a relatively small portion of the whole image. The entire surface is

    The maximum cross correlation image (white = high correlation, black = low correlation)

    And finally the surface shown in 3D with the original image mapped onto it

    展开全文
  • 首先,均值、标准差和方差的公式列出如下:     标准差描述的是样本的离散度。之所以除以n-1而不是除以n,是因为... 互相关系数公式如下, 用X、Y的协方差除以X的标准差和Y的标准差。    
  • 首先我们来看看16进制与10进制的的对比:十进制 :0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...现在来看二进制与十六进制的对应关系表:二进制与十六进制的对应关系表012340000000100100011010056789010...
  • 【前端js】时间与毫秒数互相转换

    千次阅读 2017-02-28 09:19:33
    【1】js毫秒时间转换成日期时间 var oldTime = (new Date(... //得到毫秒 //不是上面格式的时间需要转换 //starttime ='2012-12-25 20:17:24'; starttime = starttime.replace(new RegExp("-","gm"),"/"); va
  • 一:真值和机器定义 1.真值 真值是指在数值前面用“+”号表示正数,用“-”号表示负数的带符号二进制。 2.机器 机器(又称为机器码)是指在数字系统中用“0”表示符号“+”,用“1”表示符号“-”,即把...
  • 模拟域频率与数字域频率关系

    千次阅读 2017-09-25 16:02:00
    数字频率于模拟频率互相转化的公式如下: ω=2πffs\omega=\frac{2\pi f}{f_s} 通常所说的频率,在没有特别指明的情况下,指的是模拟频率,其单位为赫兹(HzHz),或者为1/秒(1/s1/s),数学符号用ff来表示。以赫兹...
  • 计算互相关注的SQL应该怎么写

    千次阅读 2019-11-27 13:14:19
    用户好友关系是一个产品的核心数据,只允许互相关注的用户之间发消息称为强关系型产品,比如微信;反之,不互相关注也能看到动态,比如微博,就是弱关系型产品 因为微信的存在,现在基本能做大的都是社区型的,弱...
  • 关系数据库与非关系数据库的区别

    万次阅读 2018-11-01 20:50:59
    当前主流的关系型数据库有Oracle、DB2、Microsoft SQL Server、Microsoft Access、MySQL等。 非关系型数据库有 NoSql、Cloudant。 nosql和关系型数据库比较? ...2)查询速度:nosql数据库将...
  • 五分钟教会你任何进制之间的互相转换

    万次阅读 多人点赞 2017-10-26 16:02:06
    对于任何一种进制—X进制,就表示某一位置上的运算时是逢X进一位。 十进制是逢十进一,十六进制是逢十六进一,二进制就是逢二进一,以此类推,x进制就是逢x进位。 常见的进制 二进制 Binary 八进制 Octal 十进制 ...
  • 偏序关系中的特殊元素问题 偏序关系证明 哈斯图 链 反链
  • 在进行系统性能压测和系统性能优化的时候,会涉及到QPS,PV,RT相关的概念, 本文总结一下QPS,PV,RT之间的关系,放在博客备忘,本文参考了之前在淘宝工作时候的一些资料。 QPS是什么? QPS:单个进程每秒请求...
  • 一、哈斯图示例 ( 整除关系 ) 、 二、哈斯图示例 ( 包含关系 ) 、 三、哈斯图示例 ( 加细关系 ) 、
  • 归一化互相关匹配

    千次阅读 2019-01-07 09:51:44
    其中,M,N分别为待匹配图像像素的行数和列,m,n分别为模板像素的行数和列。 子图Ix,y和模板T的归一化互相关值R(x,y)定义为 (1) 式中:(i,j)为像素在模板中的坐标;为子图Ix,y的像素平均值;为模板T的像...
  • json与C++结构体互相转换

    万次阅读 热门讨论 2018-02-19 21:32:17
    用于在C++结构体和json/xml/json/libconfig之间互相转换 json/xml只需要头文件, 无需编译库文件 json缺省支持,其他的需要修改config.h开启相应功能 以下例子全部以json为例,其他的类似,具体可以参考x2struct....
  • 自相关与互相关在matlab中实现

    千次阅读 2010-09-01 10:17:00
    自相关与互相关在matlab中实现
  • 为解决这一“行路难”的问题,政府决定修建公路,经过调研,如果把这7个城市之间的关系看成一个图,字母代表城市名称,数字代表修路的花费: 请回答以下问题: (1)请画出该图对应的邻接表,并写出深度优先和...
  • RGB和Bitmap互相转换

    万次阅读 2017-05-09 21:48:44
    所以决定写一个RGB和Bitmap互相转换的工具类分享给大家。1、Bitmap转RGB 获取Bitmap的RGB数组一共有两个方法,接下来简答说明下第一种方法: /** * @方法描述 Bitmap转RGB */ public static byte[] bitmap2RGB...
  • MFC的CWnd和HWND之间互相转换方法

    千次阅读 2012-12-26 20:56:07
    句柄是一个32位的,是在WINDOS中的一个资源标示符,相当于c里面的指针. 窗口类就是CWnd,窗口句柄就是HWND。CWnd和HWND之间互相转换代码如下:  CWnd *pWnd;  HWND hWnd;  hWnd = pWnd->GetSafeHwnd();...
  • 信号相关系数

    万次阅读 2018-10-29 14:35:44
    对于接收多个信号,一般可以利用相互关系(互相关系数)来衡量信号之间的关联程度。对于两个平稳信号和,其相关系数定义为: 显然相关系数满足. 若,称和不相关;若,则称和相关,若,则和完全相关。 ...
  • 过程与过程之间的关系可以分为: 交互影响关系:即两个过程之间是互相的影响的,过程A的输出影响了过程B的输出,比如需求开发过程的质量影响了需求评审过程的缺陷个的多少,影响了系统测试阶段发现的缺陷个的...
  • java中int与char之间的互相转化

    万次阅读 多人点赞 2019-04-28 15:38:12
    在java中int与char之间的互相转化 引言 数据类型 在介绍int与char的转换之前,我们先来回顾一下java中的基本数据类型: | 类型 | 大小 | 包装器类型 | | boolean | - | Boolean | | char | 16-bit | Character | | ...
  • 十进制与八进制互相转换

    千次阅读 2020-07-23 20:50:03
    与十进制转二进制方法相似,用十进制除以8取余数,商再除以8,直到商为0,余数由下到上依次排列即可,如136 136÷8=17 余0 17÷8=2 余1 2÷8=0 余2 所以八进制为210 再看小数部分,与转二进制相同,这里是乘八...
  • 连通性——介绍像素间互相连接的关系 首先说一下连接的概念,连接是指两个像素之间的关系,主要是从两方面来描述:一个是空间关系,另一个是灰度关系。 空间关系:满足连接关系的两个像素在空间上是要接触的,即两...
  • 客户关系管理核心八问

    千次阅读 2009-07-10 20:43:00
    客户关系管理。顾名思义,以管理客户关系为中心,以拉近客户关系为目标。虽然市面上流传着各种说法,但这个说法谁也不可否认,这是第一解释,否则客户关系管理就不成为“客户关系”管理了,而会是XX管理了。 我们...
  • django 外键model的互相读取

    万次阅读 2015-12-15 10:07:27
    先设定一个关系模型如下: from django.db import models class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def __str__(self): return self.nam

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 148,974
精华内容 59,589
关键字:

互相关系数