目录
range()
class range(object)
| range(stop) -> range object
| range(start, stop[, step]) -> range object
|
| Return an object that produces a sequence of integers from start (inclusive)
| to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1.
| start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3.
| These are exactly the valid indices for a list of 4 elements.
| When step is given, it specifies the increment (or decrement).
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| start
|
| step
|
| stop
range(start,stop[,step])
- Arange() is a function in the Numpy library.Its return value is an array object,often used in loops.
start represents the staring value(positive integer/negative integer),stop means the ending value(positive integer/negative integer),and step indicates the step value(the default is 1,positive integer/negative)
range(stop)
- When the output parameter is only stop,the initial value is 0.
list(range(6))
[0,1,2,3,4,5]
What is *args and **kwargs?
*args,**kwargs
numpy.reshape
if name=='main'
A friend's eyes you're a little Ming (__name__ = = 'Xiao Ming), you think you are yourself (__name__ = ='__main__'), you have a good programming, and a friend calls you to help him write a program (import Xiao Ming, when you are in your friend's eyes: __name__ = = 'Xiao Ming "), but you will also open a XX website at night and do some of your own things (direct operation Xiaoming.py,.py name__ = ='__main__'
The Unknown Word
The First Column | The Second Column |
---|---|
omitted | v.省略,遗漏 |
valid | 有效的 |
indices | ['indisi:z]指数(index的复数) |
histogram | 直方图['histe gram] |
a pair of | 一对 |
bins | 大储藏箱 |
tuple | [tapl]元组,数组 |
propagating | 反向传播['pra:pegeit] |
an error to be raised | 引发错误 |
raveling | 拆开[ravling] |
reshape | 重构 |
attribute | 属性,标志 |
三、Histogram
The Numpy histogram function applied to an array returns a pair of vectors:the histogram of the array and the vector of bins.Beware:matloblib also has a function to build histogram.(called hist
,as in Matlab)that differs from the one in NumPy.The main difference is that pylab.hist
plots the histogram automatically,while numpy.histogram only generate the data.
import numpy as np
import matplotlib.pyplot as plt
# Build a vector of 10000 normal deviates with variance 0.5^2 and mean 2
mu, sigma = 2, 0.5
v = np.random.normal(mu,sigma,10000)
# Plot a normalized histogram with 50 bins
plt.hist(v, bins=50, density=1) # matplotlib version (plot)
plt.show()