- 博客(188)
- 收藏
- 关注
转载 [Python] Scipy and Numpy(1)
import numpy as np#Create an array of 1*10^7 elementsarr = np.arange(1e7)#Converting ndarray to listlarr = arr.tolist()#Create a 2D numpy arrayarr = np.zeros((3,3))#Conver...
2017-04-11 16:02:00
196
转载 [Python] zip()
zip() is a built-infunction.zip([iterable, ...]) This function returns a list of tuples, where thei-th tuple contains thei-th element from each of the argument sequences or iterab...
2017-04-11 15:49:00
185
转载 [Python] numpy.logspace
numpy.logspace(start,stop,num=50,endpoint=True,base=10.0,dtype=None)starting value := base**startstopping value := base**stopbase = 10.0 := the base of the log spaceEx...
2017-04-11 15:00:00
273
转载 [Python] 分段线性插值
利用线性函数做插值每一段的线性函数:#Program 0.6 Linear Interploationimport numpy as npimport matplotlib.pyplot as plt#分段线性插值闭包def get_line(xn, yn): def line(x): index = -1 ...
2017-03-28 19:10:00
1605
转载 [Python] Hermite 插值
# -*- coding: utf-8 -*-#Program 0.5 Hermite Interpolationimport matplotlib.pyplot as pltimport numpy as np#计算基函数的导数值def dl(i, xi): result = 0.0 for j in ra...
2017-03-27 11:58:00
1728
转载 [Python] 牛顿插值
插值公式为:差商递归公式为:# -*- coding: utf-8 -*-#Program 0.4 Newton Interpolationimport numpy as npimport matplotlib.pyplot as plt#递归求差商def get_diff_quo(xi, fi): if len(xi) >...
2017-03-27 10:28:00
165
转载 [Python] 拉格朗日插值
#-*— coding:utf-8 -*-#Program 0.3 Lagrange Interpolationimport matplotlib.pyplot as pltimport numpy as npimport scipy as npimport random#随机生成10个介于(-255,255)的结点def getdata():...
2017-03-27 09:09:00
141
转载 [Python] numpy.nonzero
numpy.nonzero(a)Return the indices of the elements that are non-zero.Returns a tuple of arrays, one for each dimension ofa, containing the indices of the non-zero elements in that dimension....
2017-03-26 09:53:00
61
转载 [Python] numpy.random.rand
numpy.random.randnumpy.random.rand(d0,d1,...,dn)Random values in a given shape.Create an array of the given shape and populate it with random samples from a uniform distribution over[0,...
2017-03-23 22:34:00
68
转载 [Python] numpy.mat
numpy.matnumpy.mat(data,dtype=None)Interpret the input as a matrix.Unlike matrix, asmatrix does not make a copy if the input is already a matrix or an ndarray. Equivalent tomatrix(data,cop...
2017-03-23 22:26:00
99
转载 [Python] numpy.ndarray.shape
ndarray.shapeTuple of array dimensions.x = np.array([1, 2, 3, 4])print x.shape#(4, )y = np.zeros((2, 3, 4))y.shape#(2, 3, 4)y.shape = (3, 8)y#array([[ 0., 0., 0., 0....
2017-03-23 22:20:00
322
转载 [Python] numpy.sum
import numpy as np#Syntax:numpy.sum(a, axis=None, dtype=None, out=None, keepdims=<class numpy._globals._NoValue at 0x40b6a26c>) 计算中所有元素的值Example:a = [1,2]print n...
2017-03-23 22:07:00
101
转载 [Python] numpy.Matrix
import numpy as npnp.matrix('1, 2; 3, 4')#1, 2#3, 4np.matrix([[1,2],[3,4]])#1, 2#3, 4 转载于:https://www.cnblogs.com/KennyRom/p/6607589.html
2017-03-23 21:56:00
115
转载 [Python] map Method
Mapapplies a function to all the items in an input_listBlueprintmap(function, list_of_inputs) Most of the times we want to pass all the list elements to a function one-by-one ...
2017-03-23 20:57:00
122
转载 [Python] String strip() Method
DescriptionThe methodstrip()returns a copy of the string in which all chars have been stripped from the beginning and the end of the string (default whitespace characters).在string中删掉strip(c...
2017-03-23 20:48:00
104
转载 [Octave] fminunc()
fminunc( FCN, X0);fminunc( FCN, C0, Options);[X, FVEC, INFO, OUTPUT, GRAD, HESS] = fminunc (FCN, ...);%Solve an unconstrained optimization problem defined by the function FCN.%X...
2017-03-09 22:19:00
150
转载 [Octave] optimset()
Create options struct for optimization functions.optimset('parameter', value, ...);%设置所有参数及其值,未设置的为默认值optimset(optimfun);%设置与最优化函数有关的参数为默认optimset(old, 'parmeter', 'value', ....
2017-03-09 22:06:00
572
转载 [ML] CostFunction [Octave code]
function J = computeCostMulti(X, y, theta)m = length(y); % number of training examplesJ = 0;for i = 1:m J = J + (X(i,:) * theta - y(i,1)) ^ 2end;J = J / (2 * m);end...
2017-03-08 22:18:00
88
转载 [ML] Gradient Descend Algorithm [Octave code]
function [theta, J_history] = gradientDescentMulti(X, y, theta, alpha, num_iters)m = length(y); % number of training examplesJ_history = zeros(num_iters, 1);for iter = 1:num_iters ...
2017-03-08 22:17:00
84
转载 [POJ] Financial Management
Financial ManagementTime Limit:1000MSMemory Limit:10000KTotal Submissions:182193Accepted:68783DescriptionLarry graduated this year and finally has a job....
2017-03-06 19:50:00
60
转载 [POJ] 食物链
食物链Time Limit:1000MSMemory Limit:10000KTotal Submissions:68327Accepted:20199Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物...
2017-03-04 17:53:00
51
转载 [POJ] Palindrome
PalindromeTime Limit:3000MSMemory Limit:65536KTotal Submissions:62102Accepted:21643DescriptionA palindrome is a symmetrical string, that is, a string rea...
2017-03-01 23:26:00
103
转载 [POJ] The Triangle
The TriangleTime Limit:1000MSMemory Limit:10000KTotal Submissions:47278Accepted:28608Description73 88 1 02 7 4 44 5 2 6 5(Figure 1)...
2017-02-28 00:22:00
123
转载 [Cpp primer] Library vector Type
#include<vector>using std::vector;//Vector is a container. //It has a collection of same type objects.//******************************************************//Defining and ...
2017-02-21 22:44:00
60
转载 Shift Operations on C
The C standard doesn't precisely define which type of right shift should be used.For unsigned data, right shift must be logical.For signed data, almost all machine\compiler use arithmetic....
2017-02-21 22:02:00
65
转载 Masking operations
Using a mask, multiple bits in a nibble, byte, words can be set either on, off or inverted from on to off (or vice versa) in a single bitwise operation.More detail is inhttps://en.wikipedia.o...
2017-02-21 20:45:00
158
转载 [CSAPP] The Unicode Standard for text coding
The ASCII is only suitable for encoding English-language documents. It's hard for us to encode the special character.The Unicode Consortium has devised the most comprehensive and widely accept...
2017-02-21 18:27:00
69
转载 [Cpp primer] Library string Type
In order to use string type, we need to include the following code#include<string>using std::string; 1. Defining and initializing stringsstring s1; //Default initializati...
2017-02-20 23:26:00
68
转载 [Cpp primer] range for (c++11)
for (declaration : expression) statement;/*This statement will iterate through the elements in the given expression.expression: an object of a type that represents a sequencedeclarati...
2017-02-20 23:10:00
83
转载 [Cpp primer] Namespace using Declarations
If we want to use cinin the standard library, we need tostd::cinTo simplify this work, we can do like thisusing namespace::name; * Headers should not include using Declarat...
2017-02-20 21:40:00
69
转载 [CSAPP] Chapter 1 Overview of Computer
1.1 information is bits + contextAll computer programs are just a sequence of bits, each with a value of 0 or 1, organized in 8-bit chunks called by bytes.8 bits = 1 byteAll files is bin...
2017-02-13 07:48:00
166
转载 [Python] Regular Expressions
1. regular expressionRegular expression is a special sequenceof characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular ...
2017-02-06 01:19:00
82
转载 [Python] IMG to Char
Change image into characterfrom PIL import Imageimport argparse#输入#命令行输入参数处理parser = argparse.ArgumentParser()parser.add_argument('file') #position argumentparser.add_argument...
2017-01-28 08:58:00
120
转载 [Python] Argparse module
he recommended command-line parsing module in the Python standard library1. Basicimport argparseparser = argparse.ArgumentParser()parser.parse_args() $ python prog.py --hel...
2017-01-28 08:45:00
74
转载 [Python] WeChat_Robot
在微信中接入一个聊天机器人1. WeChat 个人接口itchat2. 图灵机器人#-*- coding:utf-8 -*-import itchatimport requestsapiUrl = 'http://www.tuling123.com/openapi/api'KEY = '03ea77300ddb4cf7bf243603ea84...
2017-01-27 10:34:00
160
转载 [Python] Request module
http://docs.python-requests.org/zh_CN/latest/user/quickstart.html转载于:https://www.cnblogs.com/KennyRom/p/6353666.html
2017-01-27 10:25:00
93
转载 URL
Uniform Resource Locatora reference to a websource that specifies its location on a computer network and a mechanism for retrieving itincluding: https, ftp, email(matilo) dat...
2017-01-27 10:09:00
98
转载 Python Issue: ValueError unknown locale: UTF-8 on OS X (Spyder)
In your bash_profile you lack ofsomething.addexport LANG="en_US.UTF-8"export LC_COLLATE="en_US.UTF-8"export LC_CTYPE="en_US.UTF-8"export LC_MESSAGES="en_US.UTF-8"export LC_MONETARY=...
2017-01-20 00:26:00
177
转载 Python [::-1]
a = "python"b = a[::-1]#result b is "nohtyp" 转载于:https://www.cnblogs.com/KennyRom/p/6306423.html
2017-01-19 14:09:00
55
转载 Python curses getch()
window.getch([y,x])Get a character. Note that the integer returned doesnothave to be in ASCII range: function keys, keypad keys and so on return numbers higher than 256. In no-delay mode, ...
2017-01-19 13:43:00
221
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人