我正在尝试利用Numpy的fft函数,但是当我给函数一个简单的gausian函数时,该gausian函数的fft不是gausian,它的接近但是它的一半使得每一半都在x轴的任一端.
我正在计算的高斯函数是y = exp(-x ^ 2)
这是我的代码:
from cmath import *
from numpy import multiply
from numpy.fft import fft
from pylab import plot, show
""" Basically the standard range() function but with float support """
def frange (min_value, max_value, step):
value = float(min_value)
array = []
while value < float(max_value):
array.append(value)
value += float(step)
return array
N = 256.0 # number of steps
y = []
x = frange(-5, 5, 10/N)
# fill array y with values of the Gaussian …Run Code Online (Sandbox Code Playgroud) 基本上我有兴趣知道是否存在用于科学用途的C的openGL 3D可视化工具包?
我一直试图遍历列表并将其写入文件,为什么以下不起作用?
loop_through_list(List) :-
member(Element, List),
write(Element),
write(' '),
fail.
write_list_to_file(Filename,List) :-
tell(Filename), % open file to be written
loop_through_list(List),
told. % flush buffer
Run Code Online (Sandbox Code Playgroud) 我有以下代码作为我的python服务器:
#!/usr/bin/python3
from http.server import HTTPServer, CGIHTTPRequestHandler
port = 8080
host_name = "localhost"
httpd = HTTPServer((host_name, port), CGIHTTPRequestHandler)
print("server started, to quit press <ctrl-c>")
httpd.serve_forever()
Run Code Online (Sandbox Code Playgroud)
如何设置服务器为其提供服务的DocumentRoot.
我正在使用neuralnetR中的包,但是在将绘图保存到磁盘时遇到问题.
data(iris)
attach(iris)
library(neuralnet)
nn <- neuralnet(as.numeric(Species) ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = iris)
png("test.png")
plot(nn)
dev.off()
Run Code Online (Sandbox Code Playgroud)
试图参考手册,在plot.nn()其中说:
file a character string naming the plot to write to. If not stated,
the plot will not be saved.
Run Code Online (Sandbox Code Playgroud)
但是,执行以下操作不会产生有效的图表:
png("test.png")
plot(nn, file = "test.png")
dev.off()
Run Code Online (Sandbox Code Playgroud)
平台:
Mac OSX 10.7.3
Run Code Online (Sandbox Code Playgroud)
R版:
platform x86_64-apple-darwin11.3.0
arch x86_64
os darwin11.3.0
system x86_64, darwin11.3.0
status
major 2
minor 15.1
year 2012
month 06
day 22
svn …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在Vim中探索代码折叠选项,我偶然发现了这个堆栈溢出问题.虽然我已经能够把它放到我的vimrc,但我遇到的问题是它不会折叠函数上方的多行注释.我该如何解决这个问题?
所以我被告知一个特定的谓词必须在 +,+ 模式下工作。这在 Prolog 中是什么意思?
我正在尝试通过搜索和替换来修改列表,我想知道如何搜索列表中的搜索词作为列表?
让我说我有一个列表[1,2,3,4]我想挑出2和3并用5,6替换它,所以理想情况下我可以有一个谓词:
search_and_replace(Search_Term, Replace_Term, Target_List, Result_List).
eg.
search_and_replace([2,3], [5,6], [1,2,3,4], Result_List), write(Result_List).
Run Code Online (Sandbox Code Playgroud) 我有相当相对大量的数据,有80列,约220万行.当我试图使用nnet的multinom()函数,在无序多分类数据的功能似乎经过100次迭代停止执行mutlinomial Logistic回归:
# weights: 322 (270 variable)
initial value 807521.728781
iter 10 value 191523.940813
iter 20 value 163085.728004
iter 30 value 146262.378340
iter 40 value 139398.851395
iter 50 value 134606.101687
iter 60 value 133588.725646
iter 70 value 133253.102380
iter 80 value 133129.328709
iter 90 value 133098.717752
iter 100 value 133095.661773
final value 133095.661773
stopped after 100 iterations
Run Code Online (Sandbox Code Playgroud)
我也尝试使用VGAM的vglm()但它给了我下面的错误:
Error in outer(X, Y, FUN, ...) : allocMatrix: too many elements specified
Run Code Online (Sandbox Code Playgroud)
一种可能的解释是,我的小的MacBook Air是达不到这个工作,但是我在想,我有什么其他选择在我目前拥有的数据集执行多项Logistic回归?
prolog ×3
c ×2
python ×2
r ×2
ajax ×1
dcg ×1
fft ×1
folding ×1
httpserver ×1
iso-prolog ×1
javascript ×1
markdown ×1
numpy ×1
opengl ×1
plot ×1
python-3.x ×1
regression ×1
statistics ×1
vim ×1