Matlab codes for calculation of rank order statistic (ros) by adaptive coarse grain

calculate rank order statistic (ros) by adaptive coarse grain
35 Downloads
Updated 17 May 2017

View License

function [ros,word_index]=ros_acg(x,m)
% calculate rank order statistic (ros) by adaptive coarse grain
% --------------------------
% CALL:
% [ros,word_index]=ros_acg(x,m)
% --------------------------
% INPUT:
% x - original time series
% m - word size (default 8)
% --------------------------
% OUTPUT:
% ros - rank order statistic
% word_index - word index
% --------------------------
% Matlab codes for calculation of rank order statistic (ros) by adaptive coarse grain
% --------------------------
% Reference:
% Jinshan Lin, Chunhong Dou. A novel method for condition monitoring
% of rotating machinery based on statistical linguistic analysis and weighted
% similarity measures. Journal of Sound and Vibration, 2017, 390: 272-288.
% --------------------------
% Author: Jinshan Lin
% E-mail:jslinmec@hotmail.com
% --------------------------
% Example:
% clear;
% x=randn(1,10000);
% [ros,word_index]=ros_acg(x,10);
% --------------------------
% Default parameters
if (nargin<1)
error('Not enough Input arguments');
end
if (nargin<2)
m = 8;
end

data_length=length(x);

% Convert original series into binary symbolic series
binary_series=zeros(data_length-1,1);
for i=1:data_length-1
if x(i)<x(i+1)
binary_series(i)=1;
else
binary_series(i)=0;
end
end

% Convert binary symbolic series into binary "word" according to the preset word size of m
m_bit_matrix_row_number=data_length-m;
m_bit_matrix=zeros(m_bit_matrix_row_number,m);
for j=1:m_bit_matrix_row_number
m_bit_matrix(j,:)=binary_series(j:j+m-1);
end

% Convert binary words into decimal words
m_bit_matrix_decimal=zeros(m_bit_matrix_row_number,1);
a=zeros(m,1);
for j=1:m_bit_matrix_row_number
for p=1:m
a(p)=m_bit_matrix(j,p)*2^(m-p);
m_bit_matrix_decimal(j)=a(p)+m_bit_matrix_decimal(j);
end
end

% Calculat frequency of each word
word_index=zeros(2^m,1);
for q=1:2^m
word_index(q)=length(find(m_bit_matrix_decimal==(q-1)));
end

% Calculate the descending statistic "ros" of words
ros=sort(word_index,'descend');
ros=ros/m_bit_matrix_row_number;

figure(1)
plot(word_index,'k');xlabel('Word Index');ylabel('Word Frequency');
hold on;

figure(2)
loglog(ros,'k');xlabel('Rank Index');ylabel('Probability');
hold on;

Cite As

Jinshan Lin (2025). Matlab codes for calculation of rank order statistic (ros) by adaptive coarse grain (https://se.mathworks.com/matlabcentral/fileexchange/62991-matlab-codes-for-calculation-of-rank-order-statistic-ros-by-adaptive-coarse-grain), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Publishers and Subscribers in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Matlab codes for calculation of rank order statistic (ros) by adaptive coarse grain/

Version Published Release Notes
1.0.0.0