全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2282 11
2012-04-15
请问各位大虾有没有用过hadamard矩阵?
SAS有没有自带产生这个矩阵的函数?
非常感谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-4-15 13:02:47
Here is the syntax of the function in SAS/IML

HADAMARD Function

returns a Hadamard matrix

    HADAMARD( n, <, i>)


The inputs to the HADAMARD function are as follows:

n
    specifies the order of the Hadamard matrix. Specify n such that n = 1, 2, or a multiple of 4 and any of the following hold:

        n \le 256
        n-1 is prime
        (n / 2) - 1 is prime and n / 2 = 2\; {\rm mod}\; 4
        n = 2 h, 4 h, 8 h, ..., 2^p h, where h is any n above



    When any other n is specified, the HADAMARD function returns a zero.

i
    specifies the row number to return. When i is not specified or i is negative, the full n x n matrix is returned.

The HADAMARD function returns a Hadamard matrix, which is an n x n matrix consisting entirely of the values 1 and - 1. The columns of a Hadamard matrix are all orthogonal. Hadamard matrices are frequently used to make orthogonal array experimental designs for two-level factors. For example, the following IML statements create a 12 x 12 Hadamard matrix:

  
    h = hadamard(12);
    print h[format=2.];


The results are as follows:

  
                                        H
  
                        1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
                        1  1 -1  1 -1 -1 -1  1  1  1 -1  1
                        1  1  1 -1  1 -1 -1 -1  1  1  1 -1
                        1 -1  1  1 -1  1 -1 -1 -1  1  1  1
                        1  1 -1  1  1 -1  1 -1 -1 -1  1  1
                        1  1  1 -1  1  1 -1  1 -1 -1 -1  1
                        1  1  1  1 -1  1  1 -1  1 -1 -1 -1
                        1 -1  1  1  1 -1  1  1 -1  1 -1 -1
                        1 -1 -1  1  1  1 -1  1  1 -1  1 -1
                        1 -1 -1 -1  1  1  1 -1  1  1 -1  1
                        1  1 -1 -1 -1  1  1  1 -1  1  1 -1
                        1 -1  1 -1 -1 -1  1  1  1 -1  1  1


The first column is an intercept and the next 11 columns form an orthogonal array experimental design for 11 two-level factors in 12 runs, 2^{11}.

To request the 17th row of a Hadamard matrix of order 448, use the following statement:

  
    h = hadamard(448, 17);
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-4-15 15:16:14
bobguy 发表于 2012-4-15 13:02
Here is the syntax of the function in SAS/IML

HADAMARD Function
请问是用这个语句吗?我试了一下有错误。
PROC IML;
h = hadamard(12);
print h;
RUN;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-4-16 00:30:03
mengqinqing 发表于 2012-4-15 15:16
请问是用这个语句吗?我试了一下有错误。
PROC IML;
h = hadamard(12);
Yes.

Replace the "run;" with "quit;".
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-4-16 08:51:53
bobguy 发表于 2012-4-16 00:30
Yes.

Replace the "run;" with "quit;".
但是有错误,得不到结果:
1    PROC IML;
NOTE: IML Ready
2     h = hadamard(12);
ERROR: Invocation of unresolved module HADAMARD.
statement : ASSIGN at line 2 column 2
3     print h;
ERROR: Matrix H has not been set to a value.
statement : PRINT at line 3 column 2
4    quit;
NOTE: Exiting IML.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-4-16 22:25:20
不懂
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群