我有一个分布,两个轴上的点是:
x = [21.381625583382622 ,21.201155495759807 ,21.008654068962123 ,20.90037201638843 ,20.888340677213577 ,20.701854920003328 ,20.62365121536677,
20.467243806093656 ,20.395055771044525 ,20.196538674659422 ,20.094272291673157,20.040131265386314 ,19.949896221574896 ,19.727316446840085,19.619034394266393 ,19.57090903756697 ,19.33028225406988 ,19.167859175209337 ,19.119733818509914 ,18.975357748411653 ,18.86707569583797 ,18.69863694739 ,18.620433242753442 ,18.578323555641447 ,18.27754007627008 ,18.235430389158086 ,18.169258023696383 ,17.99480360566099 ,17.86847454432501 ,17.76019249175132 ,17.639879100002773 ,17.519565708254223 ,17.278938924757128 ,17.309017272694263 ,17.122531515484013 ,16.990186784560613 ,16.875889062399487 ,16.749560001063514 ,16.64729361807725 ,16.50291754797899 ,16.394635495405296 ,16.26830643406932 ,16.11189902479621 ,16.03369532015965 ,15.91939759799853 ,15.76299018872542 ,15.648692466564295 ,15.540410413990605 ,15.408065683067202 ,15.221579925856952 ,15.071188186171264 ,15.071188186171264 ,14.87267108978616 ,14.75837336762504 ,14.674153993401056 ,14.553840601652508 ,14.409464531554251 ,14.253057122281138 ,14.19891609599429 ,14.036493017133752 ,13.843991590336074 ,13.789850564049226 ,13.669537172300679 ,13.513129763027564 ,13.392816371279016 ,13.266487309943043 ,13.140158248607065 ,12.869453117172833 ,12.82734343006084 ,12.64085767285059 ,12.496481602752333 ,12.370152541416356 ,12.261870488842664 ,12.093431740394694 ,12.003196696583283 ,11.94304000070901 ,11.75655424349876 ,11.600146834225647 ,11.497880451239382 ,11.407645407427971 ,11.19709697186801 ,11.088814919294316 ,10.992564205895478 ,10.830141127034938 ,10.7338904136361 ,10.595530013125268 ,10.469200951789292 ,10.33685622086589 ,10.180448811592775 ,10.07818242860651 ,9.957869036857963 ,9.807477297172277 ,9.687163905423729 ,9.560834844087754 ,9.452552791514059 ,9.29012971265352 ,9.1758319904924 ,9.073565607506133 ,8.953252215757583 ,8.814891815246753 ,8.54418668381252 ,8.441920300826254 ,8.297544230727997 ,8.225356195678867 ,8.050901777643471 ,7.9245727163074955 ,7.82230633332123 ,7.677930263222972 ,7.521522853949859 ,7.425272140551021 ,7.292927409627618 ,7.160582678704215 ,7.010190939018529 ,6.913940225619691 ,6.805658173045997 ,6.625188085423175 ,6.5409687111991905 ,6.4387023282129245 ,6.282294918939812 ,6.149950188016408 ,6.047683805030142 ,5.921354743694167 ,5.776978673595909 ,5.638618273085079 ,5.560414568448522 ,5.40400715917541 ,5.2716624282520055 ,5.127286358153748 ,5.0069729664052 ,4.874628235481797 ,4.730252165383538 ,4.603923104047563 ,4.49564105147387 ,4.321186633438475 ,4.218920250452209 ,4.086575519528806 ,3.9542307886054022 ,3.8218860576819993 ,3.6955569963460233 ,3.5692279350100478 ,3.4188361953243622 ,3.3045384731632415 ,3.196256420589548 ,3.0157863329667256 ,2.9014886108056044 ,2.7992222278193384 ,2.6668774968959355 ,2.534532765972532 ,2.402188035049129 ,2.2878903128880084 ,2.1435142427897502 ,1.993122503104065 ,1.8908561201177987 ,1.7585113891943958 ,1.6381979974458472 ,1.4998375969350168 ,1.3674928660116135 ,1.241163804675638 ,1.1148347433396621 ,0.9824900124162592 ,0.880223629429993 ,0.7298318897443077 ,0.6035028284083319 ,0.471158097484929 ,0.3388133665615254 ,0.21849997481297745 ,0.10420225265185667 ,-0.022126808684119315 ,-0.17251854836980485 ,-0.2868162705309256 ,-0.395098323104619 ,-0.5575214019651598 ,-0.7018974720634175 ,-0.8041638550496835 ,-0.930492916385659 ,-1.056821977721635 ,-1.1951823782324649 ,-1.3215114395684413 ,-1.441824831316989 ,-1.616279249352385 ,-1.7185456323386505 ,-1.850890363262054 ,-1.9651880854231747 ,-2.097532816346578 ,-2.2419088864448353 ,-2.3682379477808118 ,-2.512614017879069 ,-2.6329274096276176 ,-2.7291781230264567 ,-2.9036325410618513 ,-3.011914593635545 ,-3.1382436549715216 ,-3.276604055482351 ,-3.4149644559931813 ,-3.529262178154302 ,-3.64957556990285 ,-3.799967309588536 ,-3.93231204051194 ,-4.034578423498205 ,-4.172938824009036 ,-4.341377572457003 ,-4.455675294618124 ,-4.563957347191818 ,-4.714349086877503 ,-4.852709487388334 ,-4.9549758703746 ,-5.081304931710576 ,-5.243728010571116 ,-5.358025732732237 ,-5.466307785305931 ,-5.62715194579043 ,-5.730997247152738 ,-6.00170237858697 ,-6.140062779097802 ,-6.2603761708463495 ,-6.380689562594897 ,-6.494987284756018 ,-6.657410363616558 ,-6.777723755365107 ,-6.904052816701082 ,-7.042413217211912 ,-7.180773617722744 ,-7.271008661534154 ,-7.409369062044986 ,-7.55976080173067 ,-7.6860898630666465 ,-7.800387585227767 ,-7.962810664088307 ,-8.107186734186566 ,-8.191406108410549 ,-8.32976650892138 ,-8.456095570257354 ,-8.582424631593332 ,-8.672659675404743 ,-8.79297306715329 ,-9.015552841888105 ,-9.117819224874372 ,-9.208054268685784 ,-9.364461677958897 ,-9.484775069707442 ,-9.611104131043419 ,-9.695323505267403 ,-9.875793592890226 ,-10.020169662988483 ,-10.080326358862758 ,-10.26079644648558 ,-10.375094168646703 ,-10.501423229982677 ,-10.65783063925579 ,-10.760097022242057 ,-10.904473092340314 ,-11.024786484088862 ,-11.139084206249985 ,-11.337601302635088 ,-11.373695320159651 ,-11.578228086132183 ,-11.830886208804134 ,-11.95721527014011 ,-12.035418974776668 ,-12.26401441909891 ,-12.408390489197167 ,-12.40237481960974 ,-12.612923255169699 ,-12.751283655680531 ,-12.84753436907937 ,-12.991910439177627 ,-13.12425517010103 ,-13.23855289226215 ,-13.334803605660989 ,-13.503242354108957 ,-13.707775120081488 ,-13.791994494305476 ,-13.88824520770431 ,-14.056683956152279 ,-14.189028687075682 ,-14.309342078824232 ,-14.4777808272722 ,14.598094219020746 ,-14.724423280356723 ,-14.77856430643569 ,-15.019191090140664 ,-15.049269438077802 ,-15.19364550817606 ,-15.33200590868689 ,-15.494428987547431 ,-15.602711040121127 ,-15.692946083932535 ,-15.843337823618223 ,-16.077948937527893 ,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 ,3406.0 ,3890.0 ,4356.0 ,4824.0 ,5222.0 ,5621.0 ,5834.0 ,5937.0 ,5875.0 ,5838.0 ,5578.0 ,5269.0 ,4847.0 ,4403.0 ,3773.0 ,3335.0 ,2934.0 ,2420.0 ,2132.0 ,1873.0 ,1612.0 ,1425.0 ,1264.0 ,1173.0 ,1030.0 ,925.0 ,857.0 ,768.0 ,684.0 ,614.0 , 523.0 ,491.0 ,422.0 ,397.0 ,339.0 ,281.0 ,236.0 ,227.0 ,202.0 ,155.0 ,155.0 ,116.0 ,101.0 ,106.0 ,96.0 ,90.0 ,68.0 ,65.0 ,66.0 ,61.0 ,58.0 ,44.0 ,37.0 ,39.0 ,32.0 ,40.0 ,40.0 ,27.0 ,33.0 ,30.0 ,19.0 ,17.0 ,31.0 ,23.0 ,42.0 ,14.0 ,26.0 ,22.0 ,15.0 ,10.0 ,22.0 ,20.0 ,18.0 ,28.0 ,23.0 ,26.0 ,14.0 ,9.0 ,17.0 ,11.0 ,15.0 ,24.0 ,25.0 ,3.0 ,10.0 ,25.0 ,9.0 ,23.0 ,16.0 ,7.0 ,28.0 ,14.0 ,20.0 ,13.0 ,11.0 ,14.0 ,22.0 ,19.0 ,11.0 ,15.0 ,25.0 ,28.0 ,28.0 ,26.0 ,12.0 ,28.0 ,28.0 ,10.0 ,13.0 ,11.0 ,37.0 ,5.0 ,26.0 ,20.0 ,15.0 ,32.0 ,24.0 ,13.0 , 29.0 ,28.0 ,22.0 ,36.0 ,36.0 ,26.0 ,27.0 ,25.0 ,27.0 ,30.0 ,35.0 ,35.0 ,35.0 ,19.0 ,26.0 ,23.0 ,24.0 ,32.0]
我想评估分布下的面积,这是我使用的代码:
area = simps(y,x)
但是如果我运行它,它会给我这个错误:
RuntimeWarning:除以true_divide中遇到的零 y [slice1] hsum hsum / hprod + RuntimeWarning:在添加y [slice1] hsum hsum / hprod +
中遇到无效的值
我尝试打印该区域的值,但是它返回nan
值。
有人可以帮我吗?
答案 0 :(得分:0)
我已经为您自己运行了代码,发现此错误。
我建议您使用trapz
方法而不是simps
。
但是首先要注意这两个函数的数学背景 How to decide between scipy.integrate.simps or numpy.trapz?。
如果trapz
适合您,请使用:)