开发者

Reducing the dimensionality of a vector

开发者 https://www.devze.com 2023-02-18 17:43 出处:网络
How can I reduce the size of a vector to a lower dimension? Say for example X:=(1,2,3,4,5,6,7,8,9,10) is a 10-D vector. Suppose

How can I reduce the size of a vector to a lower dimension?

Say for example X:=(1,2,3,4,5,6,7,8,9,10) is a 10-D vector. Suppose I want to reduce it to a 5 dimensional space. Is there any way to do this?

开发者_C百科I have a situation where I need to compare an N-d vector with a corresponding vector of a lower dimension.


There are an infinite number of ways to convert a 10d vector into a 5d vector.

This is like saying "I want a function that takes two integer parameters and returns an integer, can I make such a function". There an infinite many such functions.

It really depends on what you want to do with the vector. What are the meanings of your 10d and 5d vectors?


If my assumption is right, the OP would like to convert a vector of 10 values to a matrix with 2 columns.

This could be done easily in R:

# make up the demo data
> v <- c(1,2,3,4,5,6,7,8,9,10)

# modify the dimensions of 'v' to have 2 columns
> dim(v) <- c(5,2)

# and check the result
> v
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号