小编kul*_*uri的帖子

Matlab到Julia优化:JuMP中的函数@SetNLObjective

我正在尝试重写Julia中的Matlab fmincon优化函数.

这是Matlab代码:

function [x,fval] = example3()

  x0 = [0; 0; 0; 0; 0; 0; 0; 0];  
  A = [];                         
  b = [];
  Ae = [1000 1000 1000 1000 -1000 -1000 -1000 -1000];   
  be = [100];                     
  lb = [0; 0; 0; 0; 0; 0; 0; 0];  
  ub = [1; 1; 1; 1; 1; 1; 1; 1];  
  noncon = [];                  

  options = optimset('fmincon');
  options.Algorithm = 'interior-point';

  [x,fval] = fmincon(@objfcn,x0,A,b,Ae,be,lb,ub,@noncon,options);

end

function f = objfcn(x) 

  % user inputs
  Cr = [ 0.0064 …
Run Code Online (Sandbox Code Playgroud)

matlab mathematical-optimization julia julia-jump

6
推荐指数
1
解决办法
800
查看次数

对称正半矩阵的MvNormal误差

我的问题的总结是我试图复制Matlab函数:

mvnrnd(mu', sigma, 200)
Run Code Online (Sandbox Code Playgroud)

进入朱莉娅使用:

rand( MvNormal(mu, sigma), 200)'
Run Code Online (Sandbox Code Playgroud)

结果是一个200 x 7矩阵,基本上产生200个随机返回时间序列数据.

Matlab的作品,朱莉娅没有.

我的输入矩阵是:

mu = [0.15; 0.03; 0.06; 0.04; 0.1; 0.02; 0.12]

sigma = [0.0035   -0.0038   0.0020    0.0017    -0.0006   -0.0028  0.0009;
    -0.0038    0.0046   -0.0011    0.0001    0.0003    0.0054   -0.0024;
    0.0020   -0.0011    0.0041    0.0068   -0.0004    0.0047   -0.0036;
    0.0017    0.0001    0.0068    0.0125    0.0002    0.0109   -0.0078;
    -0.0006    0.0003   -0.0004    0.0002    0.0025   -0.0004   -0.0007;
    -0.0028    0.0054    0.0047    0.0109   -0.0004    0.0159   -0.0093;
    0.0009   -0.0024   -0.0036   -0.0078   -0.0007   -0.0093    0.0061]
Run Code Online (Sandbox Code Playgroud)

使用Distributions.jl,运行该行:

MvNormal(sigma)
Run Code Online (Sandbox Code Playgroud)

产生错误:

ERROR: LoadError: Base.LinAlg.PosDefException(4) …
Run Code Online (Sandbox Code Playgroud)

matlab linear-algebra julia matrix-decomposition

1
推荐指数
1
解决办法
249
查看次数