Ariel Rokem | 5 Feb 06:27
Picon
Favicon
Gravatar

Comparison of mlab.csd and Matlab's cpsd

Hi everyone, 


Revisiting an issue which has already been discussed previously - in order to check whether mlab.csd really does exactly what Matlab's cpsd is doing, we wrote a couple of scripts, one in matlab and one in Python. They both run on the attached data. The comparison of the results show that they are very similar. However - two elements are off by a factor of approximately 2 - the very first element and the very last. The last one may be off just because it is very small, the difference between the two is tiny. But for the first one - this is not the case - there is actually a difference in the values. This is not only due to the fact that the DC component is very small, because even if I add a DC component to the time-series, there is still discrepancy of a factor of ~2 for that element. Does anyone have any idea why this would be the case? 

Thanks -- 

Ariel 



--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
   8.9429666e+00   5.0100717e+00  -2.6816087e+00  -7.1501559e+00  -8.0216237e+00  -8.4308386e+00 
-8.7813313e+00  -7.1541340e+00  -3.1692794e+00  -3.1233587e-02  -8.6932796e-01  -3.2208590e+00 
-2.7708292e+00  -1.1180497e+00  -1.1642218e+00   8.2827157e-01   7.7567196e+00   1.3427191e+01  
1.2297869e+01   7.9463857e+00   4.3650450e+00   7.4513721e-01  -1.8071566e+00  -1.0494220e+00  
2.7099914e-01  -6.0612992e-03   1.0650746e+00   2.7359840e+00  -2.3103312e-01  -5.4394070e+00 
-5.6020012e+00  -2.8549610e+00  -3.9441985e+00  -6.5248611e+00  -5.5182498e+00  -3.5707725e+00 
-3.3029199e+00  -1.4821612e+00   1.9829637e+00   2.9371484e+00   2.4922181e+00   4.6520641e+00  
7.6516172e+00   7.9849900e+00   6.2872303e+00   3.0524810e+00  -2.6249618e+00  -8.4729269e+00 
-1.1423490e+01  -1.1515627e+01  -8.0828989e+00  -6.1605087e-02   7.3546053e+00   7.3762039e+00  
2.7203112e+00   9.7107193e-01   2.3389000e+00   2.3308435e+00   1.0908653e+00   1.3983531e+00  
2.7507814e+00   3.1877024e+00   2.6855553e+00   2.0890036e+00   1.5431800e+00   2.6735579e-01 
-2.8915636e+00  -6.9616787e+00  -7.7022941e+00  -2.6552425e+00   3.6478430e+00   4.5449371e+00  
9.1741479e-01  -1.0349366e-01   3.1044471e+00   3.5481921e+00  -2.7689468e+00  -9.5888143e+00 
-9.2968371e+00  -3.1434409e+00   1.4650620e+00   4.9126975e-02  -4.4859946e+00  -5.1590780e+00  
1.6118592e-01   4.9388060e+00   4.1399337e+00   3.0802173e+00   7.1234314e+00   1.0353879e+01  
6.3260927e+00   5.0624656e-01  -4.3675968e-01  -2.3225964e-01  -2.4186513e+00  -1.9095391e+00  
2.5966116e+00   3.2187007e+00  -1.6422521e+00  -2.9320855e+00   1.4858112e+00   2.1743862e+00 
-3.8657803e+00  -7.4941826e+00  -3.6778977e+00   1.4465903e+00   2.0995855e+00  -3.6925935e-01 
-2.4488424e+00  -2.2657275e+00  -3.0767826e-01  -4.3447784e-02  -3.7835013e+00  -7.7710751e+00 
-6.6156223e+00  -9.8452194e-01   3.6143927e+00   3.3559741e+00  -7.0214935e-01  -4.0464556e+00 
-3.4005198e+00   3.1925151e-01   5.6106943e+00   1.2129909e+01   1.5598452e+01   1.0761346e+01  
2.7808335e+00   1.6264690e+00   4.3371698e+00   6.9655189e-01  -6.4917108e+00  -7.1557533e+00 
-3.2903321e+00  -2.5653037e+00  -2.8456560e+00  -3.8648126e-01  -3.4792857e-01  -5.4706976e+00 
-8.4354584e+00  -4.7666552e+00   1.1698809e-01   1.4126243e+00   5.2560707e-01  -1.2557422e+00 
-4.3464817e+00  -6.0548728e+00  -2.6022608e+00   3.4128104e+00   4.5097622e+00  -6.8046372e-01 
-4.1244079e+00  -2.6499816e-02   6.5978997e+00   8.9300310e+00   8.9028673e+00   1.0882147e+01  
1.1960235e+01   7.5608590e+00   3.1334125e-01  -4.6417949e+00  -6.9282767e+00  -7.4717365e+00 
-4.8990327e+00  -5.8542748e-01  -8.4564434e-02  -4.8146391e+00  -8.9187473e+00  -8.1146069e+00 
-5.1477694e+00  -3.2111192e+00  -7.1163877e-01   3.6409206e+00   6.6594649e+00   5.8487425e+00  
3.7533921e+00   3.2460105e+00   2.9353594e+00   1.0668831e+00  -5.3054098e-01  -4.1149627e-01 
-8.1327290e-01  -3.0706932e+00  -4.5485475e+00  -3.4206624e+00  -1.2170184e+00   9.6882742e-01  
2.7440724e+00   1.8368024e+00  -1.5910131e+00  -2.0317113e+00   2.4423217e+00   5.2609099e+00  
2.5027442e+00  -5.3925455e-01   3.6824003e-01   2.1030815e+00   1.6465455e+00   8.1607062e-02 
-1.1482050e+00  -9.4266580e-01   1.0252083e+00   1.3283382e+00  -2.8992882e+00  -7.2661102e+00 
-6.6027869e+00  -3.7400399e+00  -2.6018526e+00  -2.3601345e-01   5.1733118e+00   7.6959332e+00  
3.2229165e+00  -3.2443397e+00  -5.6303607e+00  -3.8377406e+00   2.4645472e-01   5.0569136e+00  
6.3004349e+00   1.3203384e+00  -3.1151906e+00   1.3232982e+00   9.5677298e+00   9.5030932e+00  
1.5131090e+00  -3.8561271e+00  -4.4258970e+00  -5.7326471e+00  -7.0638856e+00  -4.7194733e+00 
-2.2836642e+00  -3.3429743e+00  -2.5434213e+00   4.5252898e+00   1.1170906e+01   8.4467296e+00 
-1.3827260e+00  -6.9978902e+00  -3.0066829e+00   2.8550972e+00   2.1056966e+00  -1.6739241e+00 
-1.9125812e+00  -1.2343693e+00  -2.3238766e+00   3.4253954e-02   6.2718152e+00   8.3409736e+00  
5.4121519e+00   3.9103398e+00   2.6471453e+00  -2.2564369e+00  -5.9685791e+00  -5.2084251e+00 
-5.5583585e+00  -8.5601348e+00  -9.2173592e+00  -7.7095246e+00  -6.4247195e+00  -2.9195376e+00  
1.3696917e+00   2.3600111e-01  -3.5066462e+00  -1.7906518e+00   3.0267100e+00   4.4608049e+00  
4.9647577e+00   8.1244909e+00   1.0462506e+01   9.6079485e+00   7.7730961e+00   5.8355237e+00  
4.1832824e+00   4.4872281e+00   4.7070481e+00   1.1954062e+00  -3.3703080e+00  -4.2879123e+00 
-3.7852632e+00  -5.9645982e+00  -8.4869057e+00  -7.4016607e+00  -4.3441103e+00  -2.3813524e+00  
1.2418841e-01   4.9183614e+00   7.1076542e+00   1.3607427e+00  -7.3320053e+00  -8.9727762e+00 
-3.2209033e+00   1.4899373e+00   1.0741419e+00  -1.4691569e+00  -2.5938840e+00  -1.2369807e+00  
2.0206986e-01  -1.8303922e+00  -3.9449765e+00   1.4387487e+00   1.0514320e+01   1.0769771e+01
   8.8313817e+00   4.3005055e+00  -4.1649119e+00  -6.3050160e+00  -5.2402152e+00  -7.3721800e+00 
-8.1775693e+00  -3.2534988e+00   1.7048012e+00   1.8813030e+00   1.0824107e-01  -1.1253794e+00 
-2.4968623e+00  -3.3077789e+00  -2.1535871e+00   7.4321205e-01   4.6802272e+00   7.9643259e+00  
7.9943665e+00   5.5547796e+00   4.3951321e+00   4.5254200e+00   2.3442211e+00  -1.8909218e+00 
-3.5125831e+00  -7.2464997e-01   2.7212191e+00   2.5851414e+00  -9.2755899e-01  -3.8951814e+00 
-3.6401440e+00  -1.7854451e+00  -1.5882577e+00  -3.5966400e+00  -5.5301748e+00  -5.3917715e+00 
-3.4710664e+00  -1.6020516e+00  -7.3631744e-01   2.6970500e-01   2.6573457e+00   5.4863161e+00  
6.9121613e+00   6.6655222e+00   5.6622659e+00   4.0389729e+00   9.3885229e-01  -3.9502750e+00 
-8.8257786e+00  -1.0220073e+01  -6.5514972e+00  -7.9560635e-01   2.6491715e+00   3.0176599e+00  
2.3249973e+00   1.3986930e+00   4.0408014e-01   6.3290633e-01   1.6628753e+00   6.5485073e-01 
-1.8717202e+00  -1.4627624e+00   1.9782947e+00   3.2160739e+00   1.1668544e+00  -7.5422833e-02 
-3.0476741e-01  -2.7414493e+00  -5.4076926e+00  -3.5109668e+00   1.5764495e+00   4.3840966e+00  
3.4651353e+00   1.6677022e+00   1.3278134e+00   1.9641438e+00   9.7844787e-01  -2.6541428e+00 
-5.4302555e+00  -3.6952895e+00   3.5658553e-01   1.7762362e+00   3.5450667e-02  -1.0828150e+00  
8.1605611e-01   3.7404261e+00   4.2935454e+00   2.9825690e+00   3.2110963e+00   4.3252139e+00  
2.6993864e+00   2.5772192e-01   1.2371109e+00   2.0607001e+00  -2.2704400e+00  -6.6867329e+00 
-5.4038368e+00  -3.6397915e+00  -6.2586503e+00  -7.3385415e+00  -2.7550983e+00   7.9236928e-01 
-1.8886836e+00  -5.6601482e+00  -3.8104737e+00   2.8583879e+00   7.6702934e+00   5.8872419e+00  
9.0677176e-01  -1.9440434e-01   2.3735551e+00   2.3652435e+00  -7.5500799e-01  -1.8590439e+00  
7.5920807e-03   1.8605444e+00   2.7519176e+00   2.3561563e+00  -2.1737359e-01  -2.8219683e+00 
-2.2463695e+00   7.2443146e-01   3.6353362e+00   5.4375210e+00   4.7116456e+00   1.5334323e+00  
1.3049015e-01   2.1877728e+00   2.5385513e+00  -1.5107798e+00  -4.8889180e+00  -4.1843992e+00 
-2.2828085e+00  -1.0670605e+00   2.3457513e-01   2.0273180e-01  -2.0612892e+00  -3.3606344e+00 
-2.1726779e+00  -1.3180010e+00  -1.4886559e+00  -6.8853732e-01  -3.2777472e-02  -1.2468097e+00 
-2.0177334e+00  -9.4836544e-01  -4.9327480e-01  -9.0372213e-01  -6.2469066e-02   6.9582516e-01 
-2.6679510e-01  -3.0107267e-01   1.5593932e+00   2.2971845e+00   2.3280989e+00   4.3614839e+00  
5.9911319e+00   4.4196684e+00   2.4898740e+00   1.7785859e+00  -1.7747279e-03  -1.4677343e+00 
-7.7654385e-02   6.3896630e-01  -1.8932167e+00  -3.7540125e+00  -3.6034108e+00  -4.3085200e+00 
-4.2368712e+00  -1.2982768e+00   3.4464260e-01  -4.0509169e-01   1.7701181e+00   5.9147567e+00  
5.4544044e+00   1.7826749e+00   4.6335736e-01   2.0463931e-01  -1.3535767e+00  -2.0307774e+00 
-1.9379323e+00  -3.0905695e+00  -3.1283034e+00  -5.8490829e-01   9.5482502e-01   4.8349411e-01  
5.4859920e-01   2.6505302e-01  -1.6738570e+00  -2.1912486e+00   3.2643425e-02   1.8745902e+00  
1.8733346e+00   8.7274346e-01  -6.2320768e-01  -8.6521021e-01   9.8999512e-01   1.7587751e+00  
3.6997317e-01   4.6666216e-01   1.9638847e+00   7.1586139e-01  -2.7192205e+00  -4.8546551e+00 
-5.2275700e+00  -3.6331454e+00  -3.4432594e-01   8.2170170e-01  -7.7122599e-02   2.7567014e+00  
7.0580169e+00   3.6661124e+00  -4.3602951e+00  -5.1712241e+00   9.4062577e-01   4.8370393e+00  
4.8074790e+00   3.6350180e+00   1.7355182e+00   1.1764258e+00   3.3588501e+00   4.1348665e+00  
1.5457105e+00  -8.1362250e-01  -2.4892348e+00  -4.6008297e+00  -3.5153619e+00   1.8112368e-01 
-1.3466809e+00  -7.1410649e+00  -6.9291330e+00  -6.8888605e-01   2.1900116e+00   5.3854746e-01 
-6.6370732e-01  -1.2650612e+00  -1.6732370e+00   2.4574404e-01   2.5040580e+00   1.8156371e+00  
7.8117115e-01   1.9919812e+00   2.8459795e+00   2.4198319e+00   3.0987054e+00   4.2393728e+00  
3.6648485e+00   2.1428796e+00   3.8022045e-01  -2.2021776e+00  -4.1744097e+00  -4.2930744e+00 
-4.3848972e+00  -5.2515582e+00  -5.2594541e+00  -4.4249680e+00  -3.4217885e+00  -1.0180247e+00  
1.8727737e+00   1.4909976e+00  -1.6255664e+00  -2.3798025e+00   6.6177734e-01   4.0583452e+00  
5.4193601e+00   4.7630895e+00   2.7683942e+00   1.1101528e+00   1.2818523e+00   2.5446188e+00  
3.6850506e+00   4.7988971e+00   5.2451330e+00   3.4546722e+00   3.2558037e-01  -1.3030521e+00 
-1.3554915e+00  -2.6284306e+00  -5.3897891e+00  -6.1533489e+00  -3.3546173e+00  -1.5965785e-01  
6.8257969e-01   5.0294837e-01   4.3335249e-01  -1.3020608e+00  -4.4203707e+00  -4.8678613e+00 
-1.5345759e+00   1.3920361e+00   1.2277059e+00  -5.9079942e-02  -6.7115701e-01  -1.3347163e+00 
-2.3535973e+00  -2.2881480e+00   2.0879504e-01   4.4173569e+00   7.1039609e+00   5.4811765e+00
Attachment (compare_csd.m): application/octet-stream, 367 bytes
Attachment (compare_csd.py): application/octet-stream, 345 bytes
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Gmane