python
TOliverQueen
人生若只如初见
展开
-
python 一阶插值
#!/usr/bin/env python# -*-coding:utf-8 -*-import numpy as npfrom scipy import interpolateimport pylab as plx = np.linspace(0, 10, 11)# x=[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]原创 2017-10-11 17:10:10 · 5169 阅读 · 1 评论 -
二维插值
# -*- coding: utf-8 -*-"""演示二维插值。"""import numpy as npfrom scipy import interpolateimport pylab as plimport matplotlib as mpldef func(x, y): return (x + y) * np.exp(-5.0 * (x ** 2 + y **原创 2017-10-12 10:53:50 · 2090 阅读 · 0 评论 -
二维插值的三维显示
# -*- coding: utf-8 -*-"""演示二维插值。"""# -*- coding: utf-8 -*-import numpy as npfrom mpl_toolkits.mplot3d import Axes3Dimport matplotlib as mplfrom scipy import interpolateimport matplotlib.cm a原创 2017-10-12 17:04:52 · 1288 阅读 · 0 评论 -
Python基础知识
#将条件逻辑表达为数据运算import numpy as npimport sysxarr=np.array([1.1,1.2,1.3,1.4,1.5])yarr=np.array([2.1,2.2,2.3,2.4,2.5])cond=np.array([True,False,True,True,False])result=[(x if c else y) for x,y,c in ...原创 2018-08-31 09:52:19 · 125 阅读 · 0 评论 -
Python随机漫步
#时间漫步import numpy as npfrom numpy import linalgimport randomposition=0walk=[position]steps=1000for i in range(steps): step=1 if random.randint(0,1) else -1 position+=step walk.appe...原创 2018-08-31 17:05:35 · 1125 阅读 · 0 评论 -
信息增益
import numpy as npimport sysdef calc_ent(x): x_value_list = set([x[i] for i in range(x.shape[0])]) ent = 0.0 for x_value in x_value_list: p = float(x[x == x_value].shape[0]) / x...原创 2018-09-05 18:22:30 · 217 阅读 · 0 评论 -
华为机试
sabc = ''snum=''dict={}string = 'awbc2awer2tyui2'j=0i=0length=len(string)while(i<length): sabc = '' snum = '' while(i<length and string[i].isalpha()): sabc = sabc + ...原创 2018-09-05 22:15:53 · 554 阅读 · 0 评论 -
华为大数26进制
input1='z'input2='bc'sb=[chr(i) for i in range(97, 123)]list1=[x for x in input1]list2=[x for x in input2]add=[]num1=[sb.index(x) for x in list1]num2=[sb.index(x) for x in list2]if len(num1) ...原创 2018-09-05 23:25:48 · 232 阅读 · 0 评论