English 中文(简体)
简单的数据处理
原标题:Simple data processing

假设我得到了这组数据。排序后,可以按如下方式绘制分布图。

M=[-99  -99 -44.5   -7.375  -5.5    -1.666666667    -1.333333333    -1.285714286    0.436363636 2.35    3.3 4.285714286 5.052631579 6.2 7.076923077 7.230769231 7.916666667 9.7 10.66666667 16.16666667 17.4    19.2    19.6    20.75   24.25   34.5    49.5]

我的问题是如何找出那些处于中间范围的值并记录指数。使用正态分布还是其他什么?感谢你的帮助!

乔纳斯的照片

最佳回答

假设你的中间区间是[-10 10],那么指数将是:

> find(-10< M & M< 10)
ans =

    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18

请注意,您也可以通过逻辑索引访问这些值,例如:

> M(-10< M & M< 10)
ans =

 Columns 1 through 15:

  -7.37500  -5.50000  -1.66667  -1.33333  and so on ...

要获得中等射程,只需:

> q= quantile(M(:), [.25 .75])
q =

   -1.3214
   17.0917

> find(q(1)< M & M< q(2))
ans =

    8    9   10   11   12   13   14   15   16   17   18   19   20

还要注意,这里使用M(:)来确保分位数M视为向量。您可以采用程序中的所有向量都是列向量的约定,然后大多数函数会自动正确处理它们。

Update:
Now, for a very short description of quantiles is that: they are points taken from the cumulative distribution function (cdf) of a random variable. (Now your M is assumed to be a kind of cdf, since its nondecreasing and can be normalized to sum up to 1). Now simply a quantile .5 of your data means that 50% of the values are lower than this quantile . More details on quantiles can be found for example here.

问题回答

如果您不知道先验您的中间范围是什么,但您知道您希望丢弃曲线起点和终点的异常值,并且如果您有统计工具箱,您可以使用ROBUSTFIT,并且只保留内部。

M=[-99 -99 -44.5 -7.375 -5.5 -1.666666667 -1.333333333 -1.285714286 0.436363636 2.35 3.3 4.285714286 5.052631579 6.2 7.076923077 7.230769231 7.916666667 9.7 10.66666667 16.16666667 17.4 19.2 19.6 20.75 24.25 34.5 49.5];

%# robust linear regression
x = find(isfinite(M)); %# eliminate NaN or Inf
[u,s]=robustfit(x,M(x));

%# inliers have a weight > 0.25 (raise this value to be stricter)
inlierIdx = s.w > 0.25;
middleRangeX = x(inlierIdx)
middleRangeValues = M(x(inlierIdx))

%# plot with the regression in red and the good values in green
plot(x,M(x), -b. ,x,u(1)+u(2)*x, r )
hold on,plot(middleRangeX,middleRangeValues, *r )

middleRangeX =
  Columns 1 through 21
     4     5     6     7     8     9    10    11    12    13    14    15    16    17    18    19    20    21    22    23    24
  Column 22
    25
middleRangeValues =
  Columns 1 through 10
       -7.375         -5.5      -1.6667      -1.3333      -1.2857      0.43636         2.35          3.3       4.2857       5.0526
  Columns 11 through 20
          6.2       7.0769       7.2308       7.9167          9.7       10.667       16.167         17.4         19.2         19.6
  Columns 21 through 22
        20.75        24.25




相关问题
Matrix to Represent a Triangle in Screen Space

So i have a set of four points in 3D Space. P1 [0, 0, 0] P2 [128, 0, 0] P3 [0, 128, 0] P4 [128, 128, 0] Which I m then projecting orthographically to the screen effectively giving me two ...

Multiply a 3D matrix with a 2D matrix

Suppose I have an AxBxC matrix X and a BxD matrix Y. Is there a non-loop method by which I can multiply each of the C AxB matrices with Y?

matrix and vector template classes in c++

#include <array> template <typename T> class Vector4<T> { std::array<T, 4> _a; // or T _a[4]; ? }; template <typename T> class Matrix4<T> { std::array<...

Linear Independence Matrix

Suppose we have a m by n matrix A with rank m and a set K⊆{1..n} such that the columns of A indexed by K are linearly independent. Now we want to extend K and find a set L so that k⊆L and columns ...

Difference between MATLAB s matrix notations

How do you read the following MATLAB codes? #1 K>> [p,d]=eig(A) // Not sure about the syntax. p = 0.5257 -0.8507 -0.8507 -0.5257 d = ...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Java large datastructure for storing a matrix

I need to store a 2d matrix containing zip codes and the distance in km between each one of them. My client has an application that calculates the distances which are then stored in an Excel file. ...

Checking row and column for a word in python

I am trying to create a checking program to see if the word is in a matrix horizontally or vertically. I have the code for checking the row, but would checking the column be similar to the row code? ...

热门标签