我是Python的新手(以及一般的编程)我来自金融背景,所以请耐心等待.我刚开始使用Python(Enthought的Pylab/Scipy/Numpy)和R进行统计分析.我正在尝试将rpy2安装到Python中以集成R,但我得到错误:
试图猜测R的HOME但在PATH中没有R命令.
我不确定这意味着什么.我的R.exe的路径是"C:\ Program Files\R\R-2.12.1\bin",如果它有用的话.任何帮助将非常感激!
这是setup.py的代码
import os, os.path, sys, shutil, re, itertools
from distutils.command.build_ext import build_ext as _build_ext
from distutils.command.build import build as _build
from distutils.core import setup
from distutils.core import Extension
pack_name = 'rpy2'
pack_version = __import__('rpy').__version__
class build(_build):
user_options = _build.user_options + \
[
#('r-autoconfig', None,
# "guess all configuration paths from " +\
# "the R executable found in the PATH " +\
# "(this overrides r-home)"),
('r-home=', None,
"full path for the R home to …Run Code Online (Sandbox Code Playgroud) 我是Python的新手,我的线性代数有点生疏,所以这可能是一个简单的问题.我正在尝试在Matrix上实现泰勒级数展开以计算exp(A),其中A只是一个简单的3x3矩阵.该扩展的公式BTW是总和(A ^ n/n!).
我的例程工作正常,直到n = 9,但在n = 10时,矩阵中的数字突然变为负数.这就是问题.
A**9矩阵([[250130371,506767656,688136342],[159014912,322268681,437167840],[382552652,775012944,1052574077]])
A**10矩阵([[ - 1655028929,1053671123,-1327424345],[1677887954,-895075635,319718665],[-257240602,-409489685,-1776533068]])
直观地,A ^ 9*A应该为矩阵的每个成员产生更大的数字,但正如您所看到的,A ^ 10没有给出该结果.
有任何想法吗?
from scipy import *
from numpy import *
from numpy.linalg import *
#the matrix I will use to implement exp(A)
A = mat('[1 3 5; 2 5 1; 2 3 8]')
#identity matrix
I = mat('[1 0 0; 0 1 0; 0 0 1]')
#first step in Taylor Expansion (n=0)
B = I
#second step in Taylor Expansion (n=1)
B += A …Run Code Online (Sandbox Code Playgroud)