[SciPy-User] scipy.optimize fmin error

Steve Schmerler elcorto@gmx....
Fri Oct 9 02:46:03 CDT 2009


On Oct 06 20:24 +0200, Oz Nahum  wrote:

[...]
> t = array([1.0,300.0,600.0,	900.,	1200.,	1260.,	1320.,	1380, \
> 	1440,	1500,	1560,	1620,	1680,	1740,	1800,	1860,
> 	1920,	1980,	2040,	2100,	2160,	2220,	2280,	2340,\
> 	2400,	2460,	2520,	2580,	2640,	2700,	2760,	2820,\
> 	2880,	2940,	3000,	3060,	3120,	3180,	3240,	3300,\
> 	3360,	3420,	3480,	3540,	3600,	3660,	3720,	3780,\
> 	3840,	3900,	4200,	4500,	4800,	5100,	5400,	5700,\
> 	6000,	6300,	6600,	6900,	7200,	7500,	7800,	8100,\
> 	8400,	8700,	9000,	9300,	9600,	9900,   10200,	10500,\
> 	10800,	11100,	11400,	12000])
> 
> t = t.transpose()
> 
> c = array([0.07,	0.1,	0.11,	0.13,	1.17,	2.15,	3.65,	5.64,\
> 	8.12,	11,	14.3,	17.3,	20.6,	23.5,	26.5,	29.1,\
> 	31.5,	33.5,	35.3,	36.8,	37.9,	38.8,	39.5,	39.8,\
> 	40.1,	40.2,	40.1,	39.9,	39.5,	39,	38.5,	37.9,	\
> 	37.3, 36.5,	35.9,	35.1,	34.4,	33.5,	32.9,	32,	\
> 	31.2,	30.5,	29.9,	29,	28.2,	27.5,	26.8,	26.1,	\
> 	25.4,	24.7,	21.7,	19,	16.8,	14.8,	13.3,	12.1,	\
> 	11,	10.1,	9.4,	8.81,	8.15,	7.71,	7.3,	6.98,	\
> 	6.67,	6.36,	6.12,	5.92,	5.78,	5.58,	5.41,	5.15,	\
> 	4.77,	4.54,	4.37,	4.19])-0.07*1e-9*1350
> 
> c=c.transpose()
[...]

Some further small comments. t.transpose() (or t.T) is not useful for
rank 1 arrays. The shape of `t` and `c` does not change.

    # rank 1 array, shape (N,)
    In [16]: t=array([1,2,3])

    In [17]: t.shape
    Out[17]: (3,)
    
    # transpose, shape (N,)
    In [18]: t.T.shape
    Out[18]: (3,)
    
    # "row vector" in Matlab = 1xN matrix, shape (1,N)
    In [19]: trow=array([[1,2,3]])

    In [20]: trow.shape
    Out[20]: (1, 3)
    
    # column vector, shape (N,1)
    In [21]: trow.T
    Out[21]: 
    array([[1],
           [2],
           [3]])

    In [22]: trow.T.shape
    Out[22]: (3, 1)

See also http://scipy.org/NumPy_for_Matlab_Users.

best,
Steve


More information about the SciPy-User mailing list