在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:QuantEcon/CompEcon.jl开源软件地址:https://github.com/QuantEcon/CompEcon.jl开源编程语言:Julia 100.0%开源软件介绍:This package is a Julia implementation of the routines originally contained in the CompEcon Matlab toolbox by Paul Fackler and Mario Miranda. The original Matlab code was written to accompany the publication
This work is derivative of their work and has been licensed with their permission. CompEconThis package is a wrapper around BasisMatrices.jl and provides an API similar to the original CompEcon matlab library by Miranda and Fackler. For best use of the underlying routines, we recommend using the BasisMatrices.jl API. The Matlab style API here is as close to the original library as possible (differences are based mostly on syntax). To see what this means, consider the following Matlab example (taken from % function to approximate
f = @(x) exp(-x)
% Set the endpoints of approximation interval:
a = -1; % left endpoint
b = 1; % right endpoint
% Choose an approximation scheme. In this case, let us use an order 10
% Chebychev approximation scheme:
n = 10; % order of approximation
basis = fundefn('cheb',n,a,b); % define basis
% Compute the basis coefficients c. There are various way to do this:
% One may use funfitf:
c = funfitf(basis,@f);
% ... or one may compute the standard approximation nodes x and corresponding
% function values y and use funfitxy:
x = funnode(basis);
y = f(x);
c = funfitxy(basis,x,y);
% ... or one compute the standard approximation nodes x, corresponding
% function values y, and the interpolation matrix phi, and solve the
% interpolation equation directly using the backslash operator:
x = funnode(basis);
y = f(x);
phi = funbase(basis);
c = phi\y;
% Having computed the basis coefficients, one may now evaluate the
% approximant at any point x using funeval:
x = 0;
y = funeval(c,basis,x); The corresponding Julia code is using CompEcon
# function to approximate
f(x) = exp.(-x)
# Set the endpoints of approximation interval:
a = -1 # left endpoint
b = 1 # right endpoint
# Choose an approximation scheme. In this case, let us use an order 10
# Chebychev approximation scheme:
n = 10 # order of approximation
basis = fundefn(:cheb, n, a, b) # define basis
# Compute the basis coefficients c. There are various way to do this:
# One may use funfitf:
c = funfitf(basis, f)
# ... or one may compute the standard approximation nodes x and corresponding
# function values y and use funfitxy:
x = funnode(basis)[1]
y = f(x)
c = funfitxy(basis, x, y)[1]
# ... or one compute the standard approximation nodes x, corresponding
# function values y, and the interpolation matrix phi, and solve the
# interpolation equation directly using the backslash operator:
x = funnode(basis)[1]
y = f(x)
phi = funbase(basis)
c = phi\y
# Having computed the basis coefficients, one may now evaluate the
# approximant at any point x using funeval:
x = [0.0]
y = funeval(c, basis, x)[1] The main differences are:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论