본문 바로가기

언어/ㄴPython11

[pyton] numpy.cmd numpy.prod : product(곱하기) >>>numpy.prod([5, 2]) 10 numpy.zeros : generating zero array >>>numpy.zeros((3,2)) array([[0., 0.], [0., 0.], [0., 0.]]) 2016. 1. 21.
[python] generating random array 랜덤 array 생성하기. This Command is to generate random array in python interpreter. >>>z=numpy.asarray(numpy.random.RandomState(x).uniform(low=a, high=b, size=length)) or >>>rng=numpy.random.RandomState(x) >>>z=numpy.asarray(rng.uniform(low=a, high=b, size=length)) >>>z output is array([ the number of length of random unit ]) length개의 random unit이 생산된다. 범위는 a~b까지 인데 (a,b)인지 [a,b]인지 확인은 하지 못하였다. 그리고 x.. 2016. 1. 21.
[python] what is assert assert 는 assert False 일때 에러를 출력하는 function이다. Try it in the Python shell:>>> assert True >>> assert False Traceback (most recent call last): File "", line 1, in AssertionError Example ) assert(2 + 2 == 5, "Houston we've got a problem") won't work, unlikeassert 2 + 2 == 5, "Houston we've got a problem" The reason the first one doesn't work is that bool( (False, "Houston we've got a problem") )eva.. 2016. 1. 21.
[python] what is difference between numpy's 'array' and 'asarray' numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) vsnumpy.asarray(a, dtype=None, order=None) it is like array, except it has fewer options, specially copy=False. but array is copy=True The following arguments are those that may be passed to array and not asarray as mentioned in the documentation : copy : bool, optional If true (default), then the object is copied. Othe.. 2016. 1. 19.