본문 바로가기

언어30

[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.
[python] basic python 데이터 길이 : len(data) Python Expression Results Description len([1, 2, 3]) 3 Length [1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] Concatenation ['Hi!'] * 4 ['Hi!', 'Hi!', 'Hi!', 'Hi!'] Repetition 3 in [1, 2, 3] True Membership for x in [1, 2, 3]: print x, 1 2 3 Iteration ---------------------------------------------------------------------------------------------- array 구성 방식 Assuming following input −L.. 2016. 1. 19.