add_newdocs.py 181 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288
  1. # Docstrings for generated ufuncs
  2. #
  3. # The syntax is designed to look like the function add_newdoc is being
  4. # called from numpy.lib, but in this file add_newdoc puts the
  5. # docstrings in a dictionary. This dictionary is used in
  6. # _generate_pyx.py to generate the docstrings for the ufuncs in
  7. # scipy.special at the C level when the ufuncs are created at compile
  8. # time.
  9. from __future__ import division, print_function, absolute_import
  10. docdict = {}
  11. def get(name):
  12. return docdict.get(name)
  13. def add_newdoc(place, name, doc):
  14. docdict['.'.join((place, name))] = doc
  15. add_newdoc("scipy.special", "_sf_error_test_function",
  16. """
  17. Private function; do not use.
  18. """)
  19. add_newdoc("scipy.special", "sph_harm",
  20. r"""
  21. sph_harm(m, n, theta, phi)
  22. Compute spherical harmonics.
  23. The spherical harmonics are defined as
  24. .. math::
  25. Y^m_n(\theta,\phi) = \sqrt{\frac{2n+1}{4\pi} \frac{(n-m)!}{(n+m)!}}
  26. e^{i m \theta} P^m_n(\cos(\phi))
  27. where :math:`P_n^m` are the associated Legendre functions; see `lpmv`.
  28. Parameters
  29. ----------
  30. m : array_like
  31. Order of the harmonic (int); must have ``|m| <= n``.
  32. n : array_like
  33. Degree of the harmonic (int); must have ``n >= 0``. This is
  34. often denoted by ``l`` (lower case L) in descriptions of
  35. spherical harmonics.
  36. theta : array_like
  37. Azimuthal (longitudinal) coordinate; must be in ``[0, 2*pi]``.
  38. phi : array_like
  39. Polar (colatitudinal) coordinate; must be in ``[0, pi]``.
  40. Returns
  41. -------
  42. y_mn : complex float
  43. The harmonic :math:`Y^m_n` sampled at ``theta`` and ``phi``.
  44. Notes
  45. -----
  46. There are different conventions for the meanings of the input
  47. arguments ``theta`` and ``phi``. In SciPy ``theta`` is the
  48. azimuthal angle and ``phi`` is the polar angle. It is common to
  49. see the opposite convention, that is, ``theta`` as the polar angle
  50. and ``phi`` as the azimuthal angle.
  51. Note that SciPy's spherical harmonics include the Condon-Shortley
  52. phase [2]_ because it is part of `lpmv`.
  53. With SciPy's conventions, the first several spherical harmonics
  54. are
  55. .. math::
  56. Y_0^0(\theta, \phi) &= \frac{1}{2} \sqrt{\frac{1}{\pi}} \\
  57. Y_1^{-1}(\theta, \phi) &= \frac{1}{2} \sqrt{\frac{3}{2\pi}}
  58. e^{-i\theta} \sin(\phi) \\
  59. Y_1^0(\theta, \phi) &= \frac{1}{2} \sqrt{\frac{3}{\pi}}
  60. \cos(\phi) \\
  61. Y_1^1(\theta, \phi) &= -\frac{1}{2} \sqrt{\frac{3}{2\pi}}
  62. e^{i\theta} \sin(\phi).
  63. References
  64. ----------
  65. .. [1] Digital Library of Mathematical Functions, 14.30.
  66. https://dlmf.nist.gov/14.30
  67. .. [2] https://en.wikipedia.org/wiki/Spherical_harmonics#Condon.E2.80.93Shortley_phase
  68. """)
  69. add_newdoc("scipy.special", "_ellip_harm",
  70. """
  71. Internal function, use `ellip_harm` instead.
  72. """)
  73. add_newdoc("scipy.special", "_ellip_norm",
  74. """
  75. Internal function, use `ellip_norm` instead.
  76. """)
  77. add_newdoc("scipy.special", "_lambertw",
  78. """
  79. Internal function, use `lambertw` instead.
  80. """)
  81. add_newdoc("scipy.special", "wrightomega",
  82. r"""
  83. wrightomega(z, out=None)
  84. Wright Omega function.
  85. Defined as the solution to
  86. .. math::
  87. \omega + \log(\omega) = z
  88. where :math:`\log` is the principal branch of the complex logarithm.
  89. Parameters
  90. ----------
  91. z : array_like
  92. Points at which to evaluate the Wright Omega function
  93. Returns
  94. -------
  95. omega : ndarray
  96. Values of the Wright Omega function
  97. Notes
  98. -----
  99. .. versionadded:: 0.19.0
  100. The function can also be defined as
  101. .. math::
  102. \omega(z) = W_{K(z)}(e^z)
  103. where :math:`K(z) = \lceil (\Im(z) - \pi)/(2\pi) \rceil` is the
  104. unwinding number and :math:`W` is the Lambert W function.
  105. The implementation here is taken from [1]_.
  106. See Also
  107. --------
  108. lambertw : The Lambert W function
  109. References
  110. ----------
  111. .. [1] Lawrence, Corless, and Jeffrey, "Algorithm 917: Complex
  112. Double-Precision Evaluation of the Wright :math:`\omega`
  113. Function." ACM Transactions on Mathematical Software,
  114. 2012. :doi:`10.1145/2168773.2168779`.
  115. """)
  116. add_newdoc("scipy.special", "agm",
  117. """
  118. agm(a, b)
  119. Compute the arithmetic-geometric mean of `a` and `b`.
  120. Start with a_0 = a and b_0 = b and iteratively compute::
  121. a_{n+1} = (a_n + b_n)/2
  122. b_{n+1} = sqrt(a_n*b_n)
  123. a_n and b_n converge to the same limit as n increases; their common
  124. limit is agm(a, b).
  125. Parameters
  126. ----------
  127. a, b : array_like
  128. Real values only. If the values are both negative, the result
  129. is negative. If one value is negative and the other is positive,
  130. `nan` is returned.
  131. Returns
  132. -------
  133. float
  134. The arithmetic-geometric mean of `a` and `b`.
  135. Examples
  136. --------
  137. >>> from scipy.special import agm
  138. >>> a, b = 24.0, 6.0
  139. >>> agm(a, b)
  140. 13.458171481725614
  141. Compare that result to the iteration:
  142. >>> while a != b:
  143. ... a, b = (a + b)/2, np.sqrt(a*b)
  144. ... print("a = %19.16f b=%19.16f" % (a, b))
  145. ...
  146. a = 15.0000000000000000 b=12.0000000000000000
  147. a = 13.5000000000000000 b=13.4164078649987388
  148. a = 13.4582039324993694 b=13.4581390309909850
  149. a = 13.4581714817451772 b=13.4581714817060547
  150. a = 13.4581714817256159 b=13.4581714817256159
  151. When array-like arguments are given, broadcasting applies:
  152. >>> a = np.array([[1.5], [3], [6]]) # a has shape (3, 1).
  153. >>> b = np.array([6, 12, 24, 48]) # b has shape (4,).
  154. >>> agm(a, b)
  155. array([[ 3.36454287, 5.42363427, 9.05798751, 15.53650756],
  156. [ 4.37037309, 6.72908574, 10.84726853, 18.11597502],
  157. [ 6. , 8.74074619, 13.45817148, 21.69453707]])
  158. """)
  159. add_newdoc("scipy.special", "airy",
  160. r"""
  161. airy(z)
  162. Airy functions and their derivatives.
  163. Parameters
  164. ----------
  165. z : array_like
  166. Real or complex argument.
  167. Returns
  168. -------
  169. Ai, Aip, Bi, Bip : ndarrays
  170. Airy functions Ai and Bi, and their derivatives Aip and Bip.
  171. Notes
  172. -----
  173. The Airy functions Ai and Bi are two independent solutions of
  174. .. math:: y''(x) = x y(x).
  175. For real `z` in [-10, 10], the computation is carried out by calling
  176. the Cephes [1]_ `airy` routine, which uses power series summation
  177. for small `z` and rational minimax approximations for large `z`.
  178. Outside this range, the AMOS [2]_ `zairy` and `zbiry` routines are
  179. employed. They are computed using power series for :math:`|z| < 1` and
  180. the following relations to modified Bessel functions for larger `z`
  181. (where :math:`t \equiv 2 z^{3/2}/3`):
  182. .. math::
  183. Ai(z) = \frac{1}{\pi \sqrt{3}} K_{1/3}(t)
  184. Ai'(z) = -\frac{z}{\pi \sqrt{3}} K_{2/3}(t)
  185. Bi(z) = \sqrt{\frac{z}{3}} \left(I_{-1/3}(t) + I_{1/3}(t) \right)
  186. Bi'(z) = \frac{z}{\sqrt{3}} \left(I_{-2/3}(t) + I_{2/3}(t)\right)
  187. See also
  188. --------
  189. airye : exponentially scaled Airy functions.
  190. References
  191. ----------
  192. .. [1] Cephes Mathematical Functions Library,
  193. http://www.netlib.org/cephes/
  194. .. [2] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  195. of a Complex Argument and Nonnegative Order",
  196. http://netlib.org/amos/
  197. Examples
  198. --------
  199. Compute the Airy functions on the interval [-15, 5].
  200. >>> from scipy import special
  201. >>> x = np.linspace(-15, 5, 201)
  202. >>> ai, aip, bi, bip = special.airy(x)
  203. Plot Ai(x) and Bi(x).
  204. >>> import matplotlib.pyplot as plt
  205. >>> plt.plot(x, ai, 'r', label='Ai(x)')
  206. >>> plt.plot(x, bi, 'b--', label='Bi(x)')
  207. >>> plt.ylim(-0.5, 1.0)
  208. >>> plt.grid()
  209. >>> plt.legend(loc='upper left')
  210. >>> plt.show()
  211. """)
  212. add_newdoc("scipy.special", "airye",
  213. """
  214. airye(z)
  215. Exponentially scaled Airy functions and their derivatives.
  216. Scaling::
  217. eAi = Ai * exp(2.0/3.0*z*sqrt(z))
  218. eAip = Aip * exp(2.0/3.0*z*sqrt(z))
  219. eBi = Bi * exp(-abs(2.0/3.0*(z*sqrt(z)).real))
  220. eBip = Bip * exp(-abs(2.0/3.0*(z*sqrt(z)).real))
  221. Parameters
  222. ----------
  223. z : array_like
  224. Real or complex argument.
  225. Returns
  226. -------
  227. eAi, eAip, eBi, eBip : array_like
  228. Airy functions Ai and Bi, and their derivatives Aip and Bip
  229. Notes
  230. -----
  231. Wrapper for the AMOS [1]_ routines `zairy` and `zbiry`.
  232. See also
  233. --------
  234. airy
  235. References
  236. ----------
  237. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  238. of a Complex Argument and Nonnegative Order",
  239. http://netlib.org/amos/
  240. """)
  241. add_newdoc("scipy.special", "bdtr",
  242. r"""
  243. bdtr(k, n, p)
  244. Binomial distribution cumulative distribution function.
  245. Sum of the terms 0 through `k` of the Binomial probability density.
  246. .. math::
  247. \mathrm{bdtr}(k, n, p) = \sum_{j=0}^k {{n}\choose{j}} p^j (1-p)^{n-j}
  248. Parameters
  249. ----------
  250. k : array_like
  251. Number of successes (int).
  252. n : array_like
  253. Number of events (int).
  254. p : array_like
  255. Probability of success in a single event (float).
  256. Returns
  257. -------
  258. y : ndarray
  259. Probability of `k` or fewer successes in `n` independent events with
  260. success probabilities of `p`.
  261. Notes
  262. -----
  263. The terms are not summed directly; instead the regularized incomplete beta
  264. function is employed, according to the formula,
  265. .. math::
  266. \mathrm{bdtr}(k, n, p) = I_{1 - p}(n - k, k + 1).
  267. Wrapper for the Cephes [1]_ routine `bdtr`.
  268. References
  269. ----------
  270. .. [1] Cephes Mathematical Functions Library,
  271. http://www.netlib.org/cephes/
  272. """)
  273. add_newdoc("scipy.special", "bdtrc",
  274. r"""
  275. bdtrc(k, n, p)
  276. Binomial distribution survival function.
  277. Sum of the terms `k + 1` through `n` of the binomial probability density,
  278. .. math::
  279. \mathrm{bdtrc}(k, n, p) = \sum_{j=k+1}^n {{n}\choose{j}} p^j (1-p)^{n-j}
  280. Parameters
  281. ----------
  282. k : array_like
  283. Number of successes (int).
  284. n : array_like
  285. Number of events (int)
  286. p : array_like
  287. Probability of success in a single event.
  288. Returns
  289. -------
  290. y : ndarray
  291. Probability of `k + 1` or more successes in `n` independent events
  292. with success probabilities of `p`.
  293. See also
  294. --------
  295. bdtr
  296. betainc
  297. Notes
  298. -----
  299. The terms are not summed directly; instead the regularized incomplete beta
  300. function is employed, according to the formula,
  301. .. math::
  302. \mathrm{bdtrc}(k, n, p) = I_{p}(k + 1, n - k).
  303. Wrapper for the Cephes [1]_ routine `bdtrc`.
  304. References
  305. ----------
  306. .. [1] Cephes Mathematical Functions Library,
  307. http://www.netlib.org/cephes/
  308. """)
  309. add_newdoc("scipy.special", "bdtri",
  310. """
  311. bdtri(k, n, y)
  312. Inverse function to `bdtr` with respect to `p`.
  313. Finds the event probability `p` such that the sum of the terms 0 through
  314. `k` of the binomial probability density is equal to the given cumulative
  315. probability `y`.
  316. Parameters
  317. ----------
  318. k : array_like
  319. Number of successes (float).
  320. n : array_like
  321. Number of events (float)
  322. y : array_like
  323. Cumulative probability (probability of `k` or fewer successes in `n`
  324. events).
  325. Returns
  326. -------
  327. p : ndarray
  328. The event probability such that `bdtr(k, n, p) = y`.
  329. See also
  330. --------
  331. bdtr
  332. betaincinv
  333. Notes
  334. -----
  335. The computation is carried out using the inverse beta integral function
  336. and the relation,::
  337. 1 - p = betaincinv(n - k, k + 1, y).
  338. Wrapper for the Cephes [1]_ routine `bdtri`.
  339. References
  340. ----------
  341. .. [1] Cephes Mathematical Functions Library,
  342. http://www.netlib.org/cephes/
  343. """)
  344. add_newdoc("scipy.special", "bdtrik",
  345. """
  346. bdtrik(y, n, p)
  347. Inverse function to `bdtr` with respect to `k`.
  348. Finds the number of successes `k` such that the sum of the terms 0 through
  349. `k` of the Binomial probability density for `n` events with probability
  350. `p` is equal to the given cumulative probability `y`.
  351. Parameters
  352. ----------
  353. y : array_like
  354. Cumulative probability (probability of `k` or fewer successes in `n`
  355. events).
  356. n : array_like
  357. Number of events (float).
  358. p : array_like
  359. Success probability (float).
  360. Returns
  361. -------
  362. k : ndarray
  363. The number of successes `k` such that `bdtr(k, n, p) = y`.
  364. See also
  365. --------
  366. bdtr
  367. Notes
  368. -----
  369. Formula 26.5.24 of [1]_ is used to reduce the binomial distribution to the
  370. cumulative incomplete beta distribution.
  371. Computation of `k` involves a search for a value that produces the desired
  372. value of `y`. The search relies on the monotonicity of `y` with `k`.
  373. Wrapper for the CDFLIB [2]_ Fortran routine `cdfbin`.
  374. References
  375. ----------
  376. .. [1] Milton Abramowitz and Irene A. Stegun, eds.
  377. Handbook of Mathematical Functions with Formulas,
  378. Graphs, and Mathematical Tables. New York: Dover, 1972.
  379. .. [2] Barry Brown, James Lovato, and Kathy Russell,
  380. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  381. Functions, Inverses, and Other Parameters.
  382. """)
  383. add_newdoc("scipy.special", "bdtrin",
  384. """
  385. bdtrin(k, y, p)
  386. Inverse function to `bdtr` with respect to `n`.
  387. Finds the number of events `n` such that the sum of the terms 0 through
  388. `k` of the Binomial probability density for events with probability `p` is
  389. equal to the given cumulative probability `y`.
  390. Parameters
  391. ----------
  392. k : array_like
  393. Number of successes (float).
  394. y : array_like
  395. Cumulative probability (probability of `k` or fewer successes in `n`
  396. events).
  397. p : array_like
  398. Success probability (float).
  399. Returns
  400. -------
  401. n : ndarray
  402. The number of events `n` such that `bdtr(k, n, p) = y`.
  403. See also
  404. --------
  405. bdtr
  406. Notes
  407. -----
  408. Formula 26.5.24 of [1]_ is used to reduce the binomial distribution to the
  409. cumulative incomplete beta distribution.
  410. Computation of `n` involves a search for a value that produces the desired
  411. value of `y`. The search relies on the monotonicity of `y` with `n`.
  412. Wrapper for the CDFLIB [2]_ Fortran routine `cdfbin`.
  413. References
  414. ----------
  415. .. [1] Milton Abramowitz and Irene A. Stegun, eds.
  416. Handbook of Mathematical Functions with Formulas,
  417. Graphs, and Mathematical Tables. New York: Dover, 1972.
  418. .. [2] Barry Brown, James Lovato, and Kathy Russell,
  419. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  420. Functions, Inverses, and Other Parameters.
  421. """)
  422. add_newdoc("scipy.special", "binom",
  423. """
  424. binom(n, k)
  425. Binomial coefficient
  426. See Also
  427. --------
  428. comb : The number of combinations of N things taken k at a time.
  429. """)
  430. add_newdoc("scipy.special", "btdtria",
  431. r"""
  432. btdtria(p, b, x)
  433. Inverse of `btdtr` with respect to `a`.
  434. This is the inverse of the beta cumulative distribution function, `btdtr`,
  435. considered as a function of `a`, returning the value of `a` for which
  436. `btdtr(a, b, x) = p`, or
  437. .. math::
  438. p = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1}\,dt
  439. Parameters
  440. ----------
  441. p : array_like
  442. Cumulative probability, in [0, 1].
  443. b : array_like
  444. Shape parameter (`b` > 0).
  445. x : array_like
  446. The quantile, in [0, 1].
  447. Returns
  448. -------
  449. a : ndarray
  450. The value of the shape parameter `a` such that `btdtr(a, b, x) = p`.
  451. See Also
  452. --------
  453. btdtr : Cumulative density function of the beta distribution.
  454. btdtri : Inverse with respect to `x`.
  455. btdtrib : Inverse with respect to `b`.
  456. Notes
  457. -----
  458. Wrapper for the CDFLIB [1]_ Fortran routine `cdfbet`.
  459. The cumulative distribution function `p` is computed using a routine by
  460. DiDinato and Morris [2]_. Computation of `a` involves a search for a value
  461. that produces the desired value of `p`. The search relies on the
  462. monotonicity of `p` with `a`.
  463. References
  464. ----------
  465. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  466. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  467. Functions, Inverses, and Other Parameters.
  468. .. [2] DiDinato, A. R. and Morris, A. H.,
  469. Algorithm 708: Significant Digit Computation of the Incomplete Beta
  470. Function Ratios. ACM Trans. Math. Softw. 18 (1993), 360-373.
  471. """)
  472. add_newdoc("scipy.special", "btdtrib",
  473. r"""
  474. btdtria(a, p, x)
  475. Inverse of `btdtr` with respect to `b`.
  476. This is the inverse of the beta cumulative distribution function, `btdtr`,
  477. considered as a function of `b`, returning the value of `b` for which
  478. `btdtr(a, b, x) = p`, or
  479. .. math::
  480. p = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1}\,dt
  481. Parameters
  482. ----------
  483. a : array_like
  484. Shape parameter (`a` > 0).
  485. p : array_like
  486. Cumulative probability, in [0, 1].
  487. x : array_like
  488. The quantile, in [0, 1].
  489. Returns
  490. -------
  491. b : ndarray
  492. The value of the shape parameter `b` such that `btdtr(a, b, x) = p`.
  493. See Also
  494. --------
  495. btdtr : Cumulative density function of the beta distribution.
  496. btdtri : Inverse with respect to `x`.
  497. btdtria : Inverse with respect to `a`.
  498. Notes
  499. -----
  500. Wrapper for the CDFLIB [1]_ Fortran routine `cdfbet`.
  501. The cumulative distribution function `p` is computed using a routine by
  502. DiDinato and Morris [2]_. Computation of `b` involves a search for a value
  503. that produces the desired value of `p`. The search relies on the
  504. monotonicity of `p` with `b`.
  505. References
  506. ----------
  507. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  508. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  509. Functions, Inverses, and Other Parameters.
  510. .. [2] DiDinato, A. R. and Morris, A. H.,
  511. Algorithm 708: Significant Digit Computation of the Incomplete Beta
  512. Function Ratios. ACM Trans. Math. Softw. 18 (1993), 360-373.
  513. """)
  514. add_newdoc("scipy.special", "bei",
  515. """
  516. bei(x)
  517. Kelvin function bei
  518. """)
  519. add_newdoc("scipy.special", "beip",
  520. """
  521. beip(x)
  522. Derivative of the Kelvin function `bei`
  523. """)
  524. add_newdoc("scipy.special", "ber",
  525. """
  526. ber(x)
  527. Kelvin function ber.
  528. """)
  529. add_newdoc("scipy.special", "berp",
  530. """
  531. berp(x)
  532. Derivative of the Kelvin function `ber`
  533. """)
  534. add_newdoc("scipy.special", "besselpoly",
  535. r"""
  536. besselpoly(a, lmb, nu)
  537. Weighted integral of a Bessel function.
  538. .. math::
  539. \int_0^1 x^\lambda J_\nu(2 a x) \, dx
  540. where :math:`J_\nu` is a Bessel function and :math:`\lambda=lmb`,
  541. :math:`\nu=nu`.
  542. """)
  543. add_newdoc("scipy.special", "beta",
  544. """
  545. beta(a, b)
  546. Beta function.
  547. ::
  548. beta(a, b) = gamma(a) * gamma(b) / gamma(a+b)
  549. """)
  550. add_newdoc("scipy.special", "betainc",
  551. """
  552. betainc(a, b, x)
  553. Incomplete beta integral.
  554. Compute the incomplete beta integral of the arguments, evaluated
  555. from zero to `x`::
  556. gamma(a+b) / (gamma(a)*gamma(b)) * integral(t**(a-1) (1-t)**(b-1), t=0..x).
  557. Notes
  558. -----
  559. The incomplete beta is also sometimes defined without the terms
  560. in gamma, in which case the above definition is the so-called regularized
  561. incomplete beta. Under this definition, you can get the incomplete beta by
  562. multiplying the result of the scipy function by beta(a, b).
  563. """)
  564. add_newdoc("scipy.special", "betaincinv",
  565. """
  566. betaincinv(a, b, y)
  567. Inverse function to beta integral.
  568. Compute `x` such that betainc(a, b, x) = y.
  569. """)
  570. add_newdoc("scipy.special", "betaln",
  571. """
  572. betaln(a, b)
  573. Natural logarithm of absolute value of beta function.
  574. Computes ``ln(abs(beta(a, b)))``.
  575. """)
  576. add_newdoc("scipy.special", "boxcox",
  577. """
  578. boxcox(x, lmbda)
  579. Compute the Box-Cox transformation.
  580. The Box-Cox transformation is::
  581. y = (x**lmbda - 1) / lmbda if lmbda != 0
  582. log(x) if lmbda == 0
  583. Returns `nan` if ``x < 0``.
  584. Returns `-inf` if ``x == 0`` and ``lmbda < 0``.
  585. Parameters
  586. ----------
  587. x : array_like
  588. Data to be transformed.
  589. lmbda : array_like
  590. Power parameter of the Box-Cox transform.
  591. Returns
  592. -------
  593. y : array
  594. Transformed data.
  595. Notes
  596. -----
  597. .. versionadded:: 0.14.0
  598. Examples
  599. --------
  600. >>> from scipy.special import boxcox
  601. >>> boxcox([1, 4, 10], 2.5)
  602. array([ 0. , 12.4 , 126.09110641])
  603. >>> boxcox(2, [0, 1, 2])
  604. array([ 0.69314718, 1. , 1.5 ])
  605. """)
  606. add_newdoc("scipy.special", "boxcox1p",
  607. """
  608. boxcox1p(x, lmbda)
  609. Compute the Box-Cox transformation of 1 + `x`.
  610. The Box-Cox transformation computed by `boxcox1p` is::
  611. y = ((1+x)**lmbda - 1) / lmbda if lmbda != 0
  612. log(1+x) if lmbda == 0
  613. Returns `nan` if ``x < -1``.
  614. Returns `-inf` if ``x == -1`` and ``lmbda < 0``.
  615. Parameters
  616. ----------
  617. x : array_like
  618. Data to be transformed.
  619. lmbda : array_like
  620. Power parameter of the Box-Cox transform.
  621. Returns
  622. -------
  623. y : array
  624. Transformed data.
  625. Notes
  626. -----
  627. .. versionadded:: 0.14.0
  628. Examples
  629. --------
  630. >>> from scipy.special import boxcox1p
  631. >>> boxcox1p(1e-4, [0, 0.5, 1])
  632. array([ 9.99950003e-05, 9.99975001e-05, 1.00000000e-04])
  633. >>> boxcox1p([0.01, 0.1], 0.25)
  634. array([ 0.00996272, 0.09645476])
  635. """)
  636. add_newdoc("scipy.special", "inv_boxcox",
  637. """
  638. inv_boxcox(y, lmbda)
  639. Compute the inverse of the Box-Cox transformation.
  640. Find ``x`` such that::
  641. y = (x**lmbda - 1) / lmbda if lmbda != 0
  642. log(x) if lmbda == 0
  643. Parameters
  644. ----------
  645. y : array_like
  646. Data to be transformed.
  647. lmbda : array_like
  648. Power parameter of the Box-Cox transform.
  649. Returns
  650. -------
  651. x : array
  652. Transformed data.
  653. Notes
  654. -----
  655. .. versionadded:: 0.16.0
  656. Examples
  657. --------
  658. >>> from scipy.special import boxcox, inv_boxcox
  659. >>> y = boxcox([1, 4, 10], 2.5)
  660. >>> inv_boxcox(y, 2.5)
  661. array([1., 4., 10.])
  662. """)
  663. add_newdoc("scipy.special", "inv_boxcox1p",
  664. """
  665. inv_boxcox1p(y, lmbda)
  666. Compute the inverse of the Box-Cox transformation.
  667. Find ``x`` such that::
  668. y = ((1+x)**lmbda - 1) / lmbda if lmbda != 0
  669. log(1+x) if lmbda == 0
  670. Parameters
  671. ----------
  672. y : array_like
  673. Data to be transformed.
  674. lmbda : array_like
  675. Power parameter of the Box-Cox transform.
  676. Returns
  677. -------
  678. x : array
  679. Transformed data.
  680. Notes
  681. -----
  682. .. versionadded:: 0.16.0
  683. Examples
  684. --------
  685. >>> from scipy.special import boxcox1p, inv_boxcox1p
  686. >>> y = boxcox1p([1, 4, 10], 2.5)
  687. >>> inv_boxcox1p(y, 2.5)
  688. array([1., 4., 10.])
  689. """)
  690. add_newdoc("scipy.special", "btdtr",
  691. r"""
  692. btdtr(a, b, x)
  693. Cumulative density function of the beta distribution.
  694. Returns the integral from zero to `x` of the beta probability density
  695. function,
  696. .. math::
  697. I = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1}\,dt
  698. where :math:`\Gamma` is the gamma function.
  699. Parameters
  700. ----------
  701. a : array_like
  702. Shape parameter (a > 0).
  703. b : array_like
  704. Shape parameter (b > 0).
  705. x : array_like
  706. Upper limit of integration, in [0, 1].
  707. Returns
  708. -------
  709. I : ndarray
  710. Cumulative density function of the beta distribution with parameters
  711. `a` and `b` at `x`.
  712. See Also
  713. --------
  714. betainc
  715. Notes
  716. -----
  717. This function is identical to the incomplete beta integral function
  718. `betainc`.
  719. Wrapper for the Cephes [1]_ routine `btdtr`.
  720. References
  721. ----------
  722. .. [1] Cephes Mathematical Functions Library,
  723. http://www.netlib.org/cephes/
  724. """)
  725. add_newdoc("scipy.special", "btdtri",
  726. r"""
  727. btdtri(a, b, p)
  728. The `p`-th quantile of the beta distribution.
  729. This function is the inverse of the beta cumulative distribution function,
  730. `btdtr`, returning the value of `x` for which `btdtr(a, b, x) = p`, or
  731. .. math::
  732. p = \int_0^x \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} t^{a-1} (1-t)^{b-1}\,dt
  733. Parameters
  734. ----------
  735. a : array_like
  736. Shape parameter (`a` > 0).
  737. b : array_like
  738. Shape parameter (`b` > 0).
  739. p : array_like
  740. Cumulative probability, in [0, 1].
  741. Returns
  742. -------
  743. x : ndarray
  744. The quantile corresponding to `p`.
  745. See Also
  746. --------
  747. betaincinv
  748. btdtr
  749. Notes
  750. -----
  751. The value of `x` is found by interval halving or Newton iterations.
  752. Wrapper for the Cephes [1]_ routine `incbi`, which solves the equivalent
  753. problem of finding the inverse of the incomplete beta integral.
  754. References
  755. ----------
  756. .. [1] Cephes Mathematical Functions Library,
  757. http://www.netlib.org/cephes/
  758. """)
  759. add_newdoc("scipy.special", "cbrt",
  760. """
  761. cbrt(x)
  762. Element-wise cube root of `x`.
  763. Parameters
  764. ----------
  765. x : array_like
  766. `x` must contain real numbers.
  767. Returns
  768. -------
  769. float
  770. The cube root of each value in `x`.
  771. Examples
  772. --------
  773. >>> from scipy.special import cbrt
  774. >>> cbrt(8)
  775. 2.0
  776. >>> cbrt([-8, -3, 0.125, 1.331])
  777. array([-2. , -1.44224957, 0.5 , 1.1 ])
  778. """)
  779. add_newdoc("scipy.special", "chdtr",
  780. """
  781. chdtr(v, x)
  782. Chi square cumulative distribution function
  783. Returns the area under the left hand tail (from 0 to `x`) of the Chi
  784. square probability density function with `v` degrees of freedom::
  785. 1/(2**(v/2) * gamma(v/2)) * integral(t**(v/2-1) * exp(-t/2), t=0..x)
  786. """)
  787. add_newdoc("scipy.special", "chdtrc",
  788. """
  789. chdtrc(v, x)
  790. Chi square survival function
  791. Returns the area under the right hand tail (from `x` to
  792. infinity) of the Chi square probability density function with `v`
  793. degrees of freedom::
  794. 1/(2**(v/2) * gamma(v/2)) * integral(t**(v/2-1) * exp(-t/2), t=x..inf)
  795. """)
  796. add_newdoc("scipy.special", "chdtri",
  797. """
  798. chdtri(v, p)
  799. Inverse to `chdtrc`
  800. Returns the argument x such that ``chdtrc(v, x) == p``.
  801. """)
  802. add_newdoc("scipy.special", "chdtriv",
  803. """
  804. chdtriv(p, x)
  805. Inverse to `chdtr` vs `v`
  806. Returns the argument v such that ``chdtr(v, x) == p``.
  807. """)
  808. add_newdoc("scipy.special", "chndtr",
  809. """
  810. chndtr(x, df, nc)
  811. Non-central chi square cumulative distribution function
  812. """)
  813. add_newdoc("scipy.special", "chndtrix",
  814. """
  815. chndtrix(p, df, nc)
  816. Inverse to `chndtr` vs `x`
  817. """)
  818. add_newdoc("scipy.special", "chndtridf",
  819. """
  820. chndtridf(x, p, nc)
  821. Inverse to `chndtr` vs `df`
  822. """)
  823. add_newdoc("scipy.special", "chndtrinc",
  824. """
  825. chndtrinc(x, df, p)
  826. Inverse to `chndtr` vs `nc`
  827. """)
  828. add_newdoc("scipy.special", "cosdg",
  829. """
  830. cosdg(x)
  831. Cosine of the angle `x` given in degrees.
  832. """)
  833. add_newdoc("scipy.special", "cosm1",
  834. """
  835. cosm1(x)
  836. cos(x) - 1 for use when `x` is near zero.
  837. """)
  838. add_newdoc("scipy.special", "cotdg",
  839. """
  840. cotdg(x)
  841. Cotangent of the angle `x` given in degrees.
  842. """)
  843. add_newdoc("scipy.special", "dawsn",
  844. """
  845. dawsn(x)
  846. Dawson's integral.
  847. Computes::
  848. exp(-x**2) * integral(exp(t**2), t=0..x).
  849. See Also
  850. --------
  851. wofz, erf, erfc, erfcx, erfi
  852. References
  853. ----------
  854. .. [1] Steven G. Johnson, Faddeeva W function implementation.
  855. http://ab-initio.mit.edu/Faddeeva
  856. Examples
  857. --------
  858. >>> from scipy import special
  859. >>> import matplotlib.pyplot as plt
  860. >>> x = np.linspace(-15, 15, num=1000)
  861. >>> plt.plot(x, special.dawsn(x))
  862. >>> plt.xlabel('$x$')
  863. >>> plt.ylabel('$dawsn(x)$')
  864. >>> plt.show()
  865. """)
  866. add_newdoc("scipy.special", "ellipe",
  867. r"""
  868. ellipe(m)
  869. Complete elliptic integral of the second kind
  870. This function is defined as
  871. .. math:: E(m) = \int_0^{\pi/2} [1 - m \sin(t)^2]^{1/2} dt
  872. Parameters
  873. ----------
  874. m : array_like
  875. Defines the parameter of the elliptic integral.
  876. Returns
  877. -------
  878. E : ndarray
  879. Value of the elliptic integral.
  880. Notes
  881. -----
  882. Wrapper for the Cephes [1]_ routine `ellpe`.
  883. For `m > 0` the computation uses the approximation,
  884. .. math:: E(m) \approx P(1-m) - (1-m) \log(1-m) Q(1-m),
  885. where :math:`P` and :math:`Q` are tenth-order polynomials. For
  886. `m < 0`, the relation
  887. .. math:: E(m) = E(m/(m - 1)) \sqrt(1-m)
  888. is used.
  889. The parameterization in terms of :math:`m` follows that of section
  890. 17.2 in [2]_. Other parameterizations in terms of the
  891. complementary parameter :math:`1 - m`, modular angle
  892. :math:`\sin^2(\alpha) = m`, or modulus :math:`k^2 = m` are also
  893. used, so be careful that you choose the correct parameter.
  894. See Also
  895. --------
  896. ellipkm1 : Complete elliptic integral of the first kind, near `m` = 1
  897. ellipk : Complete elliptic integral of the first kind
  898. ellipkinc : Incomplete elliptic integral of the first kind
  899. ellipeinc : Incomplete elliptic integral of the second kind
  900. References
  901. ----------
  902. .. [1] Cephes Mathematical Functions Library,
  903. http://www.netlib.org/cephes/
  904. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  905. Handbook of Mathematical Functions with Formulas,
  906. Graphs, and Mathematical Tables. New York: Dover, 1972.
  907. """)
  908. add_newdoc("scipy.special", "ellipeinc",
  909. r"""
  910. ellipeinc(phi, m)
  911. Incomplete elliptic integral of the second kind
  912. This function is defined as
  913. .. math:: E(\phi, m) = \int_0^{\phi} [1 - m \sin(t)^2]^{1/2} dt
  914. Parameters
  915. ----------
  916. phi : array_like
  917. amplitude of the elliptic integral.
  918. m : array_like
  919. parameter of the elliptic integral.
  920. Returns
  921. -------
  922. E : ndarray
  923. Value of the elliptic integral.
  924. Notes
  925. -----
  926. Wrapper for the Cephes [1]_ routine `ellie`.
  927. Computation uses arithmetic-geometric means algorithm.
  928. The parameterization in terms of :math:`m` follows that of section
  929. 17.2 in [2]_. Other parameterizations in terms of the
  930. complementary parameter :math:`1 - m`, modular angle
  931. :math:`\sin^2(\alpha) = m`, or modulus :math:`k^2 = m` are also
  932. used, so be careful that you choose the correct parameter.
  933. See Also
  934. --------
  935. ellipkm1 : Complete elliptic integral of the first kind, near `m` = 1
  936. ellipk : Complete elliptic integral of the first kind
  937. ellipkinc : Incomplete elliptic integral of the first kind
  938. ellipe : Complete elliptic integral of the second kind
  939. References
  940. ----------
  941. .. [1] Cephes Mathematical Functions Library,
  942. http://www.netlib.org/cephes/
  943. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  944. Handbook of Mathematical Functions with Formulas,
  945. Graphs, and Mathematical Tables. New York: Dover, 1972.
  946. """)
  947. add_newdoc("scipy.special", "ellipj",
  948. """
  949. ellipj(u, m)
  950. Jacobian elliptic functions
  951. Calculates the Jacobian elliptic functions of parameter `m` between
  952. 0 and 1, and real argument `u`.
  953. Parameters
  954. ----------
  955. m : array_like
  956. Parameter.
  957. u : array_like
  958. Argument.
  959. Returns
  960. -------
  961. sn, cn, dn, ph : ndarrays
  962. The returned functions::
  963. sn(u|m), cn(u|m), dn(u|m)
  964. The value `ph` is such that if `u = ellipk(ph, m)`,
  965. then `sn(u|m) = sin(ph)` and `cn(u|m) = cos(ph)`.
  966. Notes
  967. -----
  968. Wrapper for the Cephes [1]_ routine `ellpj`.
  969. These functions are periodic, with quarter-period on the real axis
  970. equal to the complete elliptic integral `ellipk(m)`.
  971. Relation to incomplete elliptic integral: If `u = ellipk(phi,m)`, then
  972. `sn(u|m) = sin(phi)`, and `cn(u|m) = cos(phi)`. The `phi` is called
  973. the amplitude of `u`.
  974. Computation is by means of the arithmetic-geometric mean algorithm,
  975. except when `m` is within 1e-9 of 0 or 1. In the latter case with `m`
  976. close to 1, the approximation applies only for `phi < pi/2`.
  977. See also
  978. --------
  979. ellipk : Complete elliptic integral of the first kind.
  980. References
  981. ----------
  982. .. [1] Cephes Mathematical Functions Library,
  983. http://www.netlib.org/cephes/
  984. """)
  985. add_newdoc("scipy.special", "ellipkm1",
  986. """
  987. ellipkm1(p)
  988. Complete elliptic integral of the first kind around `m` = 1
  989. This function is defined as
  990. .. math:: K(p) = \\int_0^{\\pi/2} [1 - m \\sin(t)^2]^{-1/2} dt
  991. where `m = 1 - p`.
  992. Parameters
  993. ----------
  994. p : array_like
  995. Defines the parameter of the elliptic integral as `m = 1 - p`.
  996. Returns
  997. -------
  998. K : ndarray
  999. Value of the elliptic integral.
  1000. Notes
  1001. -----
  1002. Wrapper for the Cephes [1]_ routine `ellpk`.
  1003. For `p <= 1`, computation uses the approximation,
  1004. .. math:: K(p) \\approx P(p) - \\log(p) Q(p),
  1005. where :math:`P` and :math:`Q` are tenth-order polynomials. The
  1006. argument `p` is used internally rather than `m` so that the logarithmic
  1007. singularity at `m = 1` will be shifted to the origin; this preserves
  1008. maximum accuracy. For `p > 1`, the identity
  1009. .. math:: K(p) = K(1/p)/\\sqrt(p)
  1010. is used.
  1011. See Also
  1012. --------
  1013. ellipk : Complete elliptic integral of the first kind
  1014. ellipkinc : Incomplete elliptic integral of the first kind
  1015. ellipe : Complete elliptic integral of the second kind
  1016. ellipeinc : Incomplete elliptic integral of the second kind
  1017. References
  1018. ----------
  1019. .. [1] Cephes Mathematical Functions Library,
  1020. http://www.netlib.org/cephes/
  1021. """)
  1022. add_newdoc("scipy.special", "ellipkinc",
  1023. r"""
  1024. ellipkinc(phi, m)
  1025. Incomplete elliptic integral of the first kind
  1026. This function is defined as
  1027. .. math:: K(\phi, m) = \int_0^{\phi} [1 - m \sin(t)^2]^{-1/2} dt
  1028. This function is also called `F(phi, m)`.
  1029. Parameters
  1030. ----------
  1031. phi : array_like
  1032. amplitude of the elliptic integral
  1033. m : array_like
  1034. parameter of the elliptic integral
  1035. Returns
  1036. -------
  1037. K : ndarray
  1038. Value of the elliptic integral
  1039. Notes
  1040. -----
  1041. Wrapper for the Cephes [1]_ routine `ellik`. The computation is
  1042. carried out using the arithmetic-geometric mean algorithm.
  1043. The parameterization in terms of :math:`m` follows that of section
  1044. 17.2 in [2]_. Other parameterizations in terms of the
  1045. complementary parameter :math:`1 - m`, modular angle
  1046. :math:`\sin^2(\alpha) = m`, or modulus :math:`k^2 = m` are also
  1047. used, so be careful that you choose the correct parameter.
  1048. See Also
  1049. --------
  1050. ellipkm1 : Complete elliptic integral of the first kind, near `m` = 1
  1051. ellipk : Complete elliptic integral of the first kind
  1052. ellipe : Complete elliptic integral of the second kind
  1053. ellipeinc : Incomplete elliptic integral of the second kind
  1054. References
  1055. ----------
  1056. .. [1] Cephes Mathematical Functions Library,
  1057. http://www.netlib.org/cephes/
  1058. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  1059. Handbook of Mathematical Functions with Formulas,
  1060. Graphs, and Mathematical Tables. New York: Dover, 1972.
  1061. """)
  1062. add_newdoc("scipy.special", "entr",
  1063. r"""
  1064. entr(x)
  1065. Elementwise function for computing entropy.
  1066. .. math:: \text{entr}(x) = \begin{cases} - x \log(x) & x > 0 \\ 0 & x = 0 \\ -\infty & \text{otherwise} \end{cases}
  1067. Parameters
  1068. ----------
  1069. x : ndarray
  1070. Input array.
  1071. Returns
  1072. -------
  1073. res : ndarray
  1074. The value of the elementwise entropy function at the given points `x`.
  1075. See Also
  1076. --------
  1077. kl_div, rel_entr
  1078. Notes
  1079. -----
  1080. This function is concave.
  1081. .. versionadded:: 0.15.0
  1082. """)
  1083. add_newdoc("scipy.special", "erf",
  1084. """
  1085. erf(z)
  1086. Returns the error function of complex argument.
  1087. It is defined as ``2/sqrt(pi)*integral(exp(-t**2), t=0..z)``.
  1088. Parameters
  1089. ----------
  1090. x : ndarray
  1091. Input array.
  1092. Returns
  1093. -------
  1094. res : ndarray
  1095. The values of the error function at the given points `x`.
  1096. See Also
  1097. --------
  1098. erfc, erfinv, erfcinv, wofz, erfcx, erfi
  1099. Notes
  1100. -----
  1101. The cumulative of the unit normal distribution is given by
  1102. ``Phi(z) = 1/2[1 + erf(z/sqrt(2))]``.
  1103. References
  1104. ----------
  1105. .. [1] https://en.wikipedia.org/wiki/Error_function
  1106. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  1107. Handbook of Mathematical Functions with Formulas,
  1108. Graphs, and Mathematical Tables. New York: Dover,
  1109. 1972. http://www.math.sfu.ca/~cbm/aands/page_297.htm
  1110. .. [3] Steven G. Johnson, Faddeeva W function implementation.
  1111. http://ab-initio.mit.edu/Faddeeva
  1112. Examples
  1113. --------
  1114. >>> from scipy import special
  1115. >>> import matplotlib.pyplot as plt
  1116. >>> x = np.linspace(-3, 3)
  1117. >>> plt.plot(x, special.erf(x))
  1118. >>> plt.xlabel('$x$')
  1119. >>> plt.ylabel('$erf(x)$')
  1120. >>> plt.show()
  1121. """)
  1122. add_newdoc("scipy.special", "erfc",
  1123. """
  1124. erfc(x)
  1125. Complementary error function, ``1 - erf(x)``.
  1126. See Also
  1127. --------
  1128. erf, erfi, erfcx, dawsn, wofz
  1129. References
  1130. ----------
  1131. .. [1] Steven G. Johnson, Faddeeva W function implementation.
  1132. http://ab-initio.mit.edu/Faddeeva
  1133. Examples
  1134. --------
  1135. >>> from scipy import special
  1136. >>> import matplotlib.pyplot as plt
  1137. >>> x = np.linspace(-3, 3)
  1138. >>> plt.plot(x, special.erfc(x))
  1139. >>> plt.xlabel('$x$')
  1140. >>> plt.ylabel('$erfc(x)$')
  1141. >>> plt.show()
  1142. """)
  1143. add_newdoc("scipy.special", "erfi",
  1144. """
  1145. erfi(z)
  1146. Imaginary error function, ``-i erf(i z)``.
  1147. See Also
  1148. --------
  1149. erf, erfc, erfcx, dawsn, wofz
  1150. Notes
  1151. -----
  1152. .. versionadded:: 0.12.0
  1153. References
  1154. ----------
  1155. .. [1] Steven G. Johnson, Faddeeva W function implementation.
  1156. http://ab-initio.mit.edu/Faddeeva
  1157. Examples
  1158. --------
  1159. >>> from scipy import special
  1160. >>> import matplotlib.pyplot as plt
  1161. >>> x = np.linspace(-3, 3)
  1162. >>> plt.plot(x, special.erfi(x))
  1163. >>> plt.xlabel('$x$')
  1164. >>> plt.ylabel('$erfi(x)$')
  1165. >>> plt.show()
  1166. """)
  1167. add_newdoc("scipy.special", "erfcx",
  1168. """
  1169. erfcx(x)
  1170. Scaled complementary error function, ``exp(x**2) * erfc(x)``.
  1171. See Also
  1172. --------
  1173. erf, erfc, erfi, dawsn, wofz
  1174. Notes
  1175. -----
  1176. .. versionadded:: 0.12.0
  1177. References
  1178. ----------
  1179. .. [1] Steven G. Johnson, Faddeeva W function implementation.
  1180. http://ab-initio.mit.edu/Faddeeva
  1181. Examples
  1182. --------
  1183. >>> from scipy import special
  1184. >>> import matplotlib.pyplot as plt
  1185. >>> x = np.linspace(-3, 3)
  1186. >>> plt.plot(x, special.erfcx(x))
  1187. >>> plt.xlabel('$x$')
  1188. >>> plt.ylabel('$erfcx(x)$')
  1189. >>> plt.show()
  1190. """)
  1191. add_newdoc("scipy.special", "eval_jacobi",
  1192. r"""
  1193. eval_jacobi(n, alpha, beta, x, out=None)
  1194. Evaluate Jacobi polynomial at a point.
  1195. The Jacobi polynomials can be defined via the Gauss hypergeometric
  1196. function :math:`{}_2F_1` as
  1197. .. math::
  1198. P_n^{(\alpha, \beta)}(x) = \frac{(\alpha + 1)_n}{\Gamma(n + 1)}
  1199. {}_2F_1(-n, 1 + \alpha + \beta + n; \alpha + 1; (1 - z)/2)
  1200. where :math:`(\cdot)_n` is the Pochhammer symbol; see `poch`. When
  1201. :math:`n` is an integer the result is a polynomial of degree
  1202. :math:`n`.
  1203. Parameters
  1204. ----------
  1205. n : array_like
  1206. Degree of the polynomial. If not an integer the result is
  1207. determined via the relation to the Gauss hypergeometric
  1208. function.
  1209. alpha : array_like
  1210. Parameter
  1211. beta : array_like
  1212. Parameter
  1213. x : array_like
  1214. Points at which to evaluate the polynomial
  1215. Returns
  1216. -------
  1217. P : ndarray
  1218. Values of the Jacobi polynomial
  1219. See Also
  1220. --------
  1221. roots_jacobi : roots and quadrature weights of Jacobi polynomials
  1222. jacobi : Jacobi polynomial object
  1223. hyp2f1 : Gauss hypergeometric function
  1224. """)
  1225. add_newdoc("scipy.special", "eval_sh_jacobi",
  1226. r"""
  1227. eval_sh_jacobi(n, p, q, x, out=None)
  1228. Evaluate shifted Jacobi polynomial at a point.
  1229. Defined by
  1230. .. math::
  1231. G_n^{(p, q)}(x)
  1232. = \binom{2n + p - 1}{n}^{-1} P_n^{(p - q, q - 1)}(2x - 1),
  1233. where :math:`P_n^{(\cdot, \cdot)}` is the n-th Jacobi polynomial.
  1234. Parameters
  1235. ----------
  1236. n : int
  1237. Degree of the polynomial. If not an integer, the result is
  1238. determined via the relation to `binom` and `eval_jacobi`.
  1239. p : float
  1240. Parameter
  1241. q : float
  1242. Parameter
  1243. Returns
  1244. -------
  1245. G : ndarray
  1246. Values of the shifted Jacobi polynomial.
  1247. See Also
  1248. --------
  1249. roots_sh_jacobi : roots and quadrature weights of shifted Jacobi
  1250. polynomials
  1251. sh_jacobi : shifted Jacobi polynomial object
  1252. eval_jacobi : evaluate Jacobi polynomials
  1253. """)
  1254. add_newdoc("scipy.special", "eval_gegenbauer",
  1255. r"""
  1256. eval_gegenbauer(n, alpha, x, out=None)
  1257. Evaluate Gegenbauer polynomial at a point.
  1258. The Gegenbauer polynomials can be defined via the Gauss
  1259. hypergeometric function :math:`{}_2F_1` as
  1260. .. math::
  1261. C_n^{(\alpha)} = \frac{(2\alpha)_n}{\Gamma(n + 1)}
  1262. {}_2F_1(-n, 2\alpha + n; \alpha + 1/2; (1 - z)/2).
  1263. When :math:`n` is an integer the result is a polynomial of degree
  1264. :math:`n`.
  1265. Parameters
  1266. ----------
  1267. n : array_like
  1268. Degree of the polynomial. If not an integer, the result is
  1269. determined via the relation to the Gauss hypergeometric
  1270. function.
  1271. alpha : array_like
  1272. Parameter
  1273. x : array_like
  1274. Points at which to evaluate the Gegenbauer polynomial
  1275. Returns
  1276. -------
  1277. C : ndarray
  1278. Values of the Gegenbauer polynomial
  1279. See Also
  1280. --------
  1281. roots_gegenbauer : roots and quadrature weights of Gegenbauer
  1282. polynomials
  1283. gegenbauer : Gegenbauer polynomial object
  1284. hyp2f1 : Gauss hypergeometric function
  1285. """)
  1286. add_newdoc("scipy.special", "eval_chebyt",
  1287. r"""
  1288. eval_chebyt(n, x, out=None)
  1289. Evaluate Chebyshev polynomial of the first kind at a point.
  1290. The Chebyshev polynomials of the first kind can be defined via the
  1291. Gauss hypergeometric function :math:`{}_2F_1` as
  1292. .. math::
  1293. T_n(x) = {}_2F_1(n, -n; 1/2; (1 - x)/2).
  1294. When :math:`n` is an integer the result is a polynomial of degree
  1295. :math:`n`.
  1296. Parameters
  1297. ----------
  1298. n : array_like
  1299. Degree of the polynomial. If not an integer, the result is
  1300. determined via the relation to the Gauss hypergeometric
  1301. function.
  1302. x : array_like
  1303. Points at which to evaluate the Chebyshev polynomial
  1304. Returns
  1305. -------
  1306. T : ndarray
  1307. Values of the Chebyshev polynomial
  1308. See Also
  1309. --------
  1310. roots_chebyt : roots and quadrature weights of Chebyshev
  1311. polynomials of the first kind
  1312. chebyu : Chebychev polynomial object
  1313. eval_chebyu : evaluate Chebyshev polynomials of the second kind
  1314. hyp2f1 : Gauss hypergeometric function
  1315. numpy.polynomial.chebyshev.Chebyshev : Chebyshev series
  1316. Notes
  1317. -----
  1318. This routine is numerically stable for `x` in ``[-1, 1]`` at least
  1319. up to order ``10000``.
  1320. """)
  1321. add_newdoc("scipy.special", "eval_chebyu",
  1322. r"""
  1323. eval_chebyu(n, x, out=None)
  1324. Evaluate Chebyshev polynomial of the second kind at a point.
  1325. The Chebyshev polynomials of the second kind can be defined via
  1326. the Gauss hypergeometric function :math:`{}_2F_1` as
  1327. .. math::
  1328. U_n(x) = (n + 1) {}_2F_1(-n, n + 2; 3/2; (1 - x)/2).
  1329. When :math:`n` is an integer the result is a polynomial of degree
  1330. :math:`n`.
  1331. Parameters
  1332. ----------
  1333. n : array_like
  1334. Degree of the polynomial. If not an integer, the result is
  1335. determined via the relation to the Gauss hypergeometric
  1336. function.
  1337. x : array_like
  1338. Points at which to evaluate the Chebyshev polynomial
  1339. Returns
  1340. -------
  1341. U : ndarray
  1342. Values of the Chebyshev polynomial
  1343. See Also
  1344. --------
  1345. roots_chebyu : roots and quadrature weights of Chebyshev
  1346. polynomials of the second kind
  1347. chebyu : Chebyshev polynomial object
  1348. eval_chebyt : evaluate Chebyshev polynomials of the first kind
  1349. hyp2f1 : Gauss hypergeometric function
  1350. """)
  1351. add_newdoc("scipy.special", "eval_chebys",
  1352. r"""
  1353. eval_chebys(n, x, out=None)
  1354. Evaluate Chebyshev polynomial of the second kind on [-2, 2] at a
  1355. point.
  1356. These polynomials are defined as
  1357. .. math::
  1358. S_n(x) = U_n(x/2)
  1359. where :math:`U_n` is a Chebyshev polynomial of the second kind.
  1360. Parameters
  1361. ----------
  1362. n : array_like
  1363. Degree of the polynomial. If not an integer, the result is
  1364. determined via the relation to `eval_chebyu`.
  1365. x : array_like
  1366. Points at which to evaluate the Chebyshev polynomial
  1367. Returns
  1368. -------
  1369. S : ndarray
  1370. Values of the Chebyshev polynomial
  1371. See Also
  1372. --------
  1373. roots_chebys : roots and quadrature weights of Chebyshev
  1374. polynomials of the second kind on [-2, 2]
  1375. chebys : Chebyshev polynomial object
  1376. eval_chebyu : evaluate Chebyshev polynomials of the second kind
  1377. """)
  1378. add_newdoc("scipy.special", "eval_chebyc",
  1379. r"""
  1380. eval_chebyc(n, x, out=None)
  1381. Evaluate Chebyshev polynomial of the first kind on [-2, 2] at a
  1382. point.
  1383. These polynomials are defined as
  1384. .. math::
  1385. S_n(x) = T_n(x/2)
  1386. where :math:`T_n` is a Chebyshev polynomial of the first kind.
  1387. Parameters
  1388. ----------
  1389. n : array_like
  1390. Degree of the polynomial. If not an integer, the result is
  1391. determined via the relation to `eval_chebyt`.
  1392. x : array_like
  1393. Points at which to evaluate the Chebyshev polynomial
  1394. Returns
  1395. -------
  1396. C : ndarray
  1397. Values of the Chebyshev polynomial
  1398. See Also
  1399. --------
  1400. roots_chebyc : roots and quadrature weights of Chebyshev
  1401. polynomials of the first kind on [-2, 2]
  1402. chebyc : Chebyshev polynomial object
  1403. numpy.polynomial.chebyshev.Chebyshev : Chebyshev series
  1404. eval_chebyt : evaluate Chebycshev polynomials of the first kind
  1405. """)
  1406. add_newdoc("scipy.special", "eval_sh_chebyt",
  1407. r"""
  1408. eval_sh_chebyt(n, x, out=None)
  1409. Evaluate shifted Chebyshev polynomial of the first kind at a
  1410. point.
  1411. These polynomials are defined as
  1412. .. math::
  1413. T_n^*(x) = T_n(2x - 1)
  1414. where :math:`T_n` is a Chebyshev polynomial of the first kind.
  1415. Parameters
  1416. ----------
  1417. n : array_like
  1418. Degree of the polynomial. If not an integer, the result is
  1419. determined via the relation to `eval_chebyt`.
  1420. x : array_like
  1421. Points at which to evaluate the shifted Chebyshev polynomial
  1422. Returns
  1423. -------
  1424. T : ndarray
  1425. Values of the shifted Chebyshev polynomial
  1426. See Also
  1427. --------
  1428. roots_sh_chebyt : roots and quadrature weights of shifted
  1429. Chebyshev polynomials of the first kind
  1430. sh_chebyt : shifted Chebyshev polynomial object
  1431. eval_chebyt : evaluate Chebyshev polynomials of the first kind
  1432. numpy.polynomial.chebyshev.Chebyshev : Chebyshev series
  1433. """)
  1434. add_newdoc("scipy.special", "eval_sh_chebyu",
  1435. r"""
  1436. eval_sh_chebyu(n, x, out=None)
  1437. Evaluate shifted Chebyshev polynomial of the second kind at a
  1438. point.
  1439. These polynomials are defined as
  1440. .. math::
  1441. U_n^*(x) = U_n(2x - 1)
  1442. where :math:`U_n` is a Chebyshev polynomial of the first kind.
  1443. Parameters
  1444. ----------
  1445. n : array_like
  1446. Degree of the polynomial. If not an integer, the result is
  1447. determined via the relation to `eval_chebyu`.
  1448. x : array_like
  1449. Points at which to evaluate the shifted Chebyshev polynomial
  1450. Returns
  1451. -------
  1452. U : ndarray
  1453. Values of the shifted Chebyshev polynomial
  1454. See Also
  1455. --------
  1456. roots_sh_chebyu : roots and quadrature weights of shifted
  1457. Chebychev polynomials of the second kind
  1458. sh_chebyu : shifted Chebyshev polynomial object
  1459. eval_chebyu : evaluate Chebyshev polynomials of the second kind
  1460. """)
  1461. add_newdoc("scipy.special", "eval_legendre",
  1462. r"""
  1463. eval_legendre(n, x, out=None)
  1464. Evaluate Legendre polynomial at a point.
  1465. The Legendre polynomials can be defined via the Gauss
  1466. hypergeometric function :math:`{}_2F_1` as
  1467. .. math::
  1468. P_n(x) = {}_2F_1(-n, n + 1; 1; (1 - x)/2).
  1469. When :math:`n` is an integer the result is a polynomial of degree
  1470. :math:`n`.
  1471. Parameters
  1472. ----------
  1473. n : array_like
  1474. Degree of the polynomial. If not an integer, the result is
  1475. determined via the relation to the Gauss hypergeometric
  1476. function.
  1477. x : array_like
  1478. Points at which to evaluate the Legendre polynomial
  1479. Returns
  1480. -------
  1481. P : ndarray
  1482. Values of the Legendre polynomial
  1483. See Also
  1484. --------
  1485. roots_legendre : roots and quadrature weights of Legendre
  1486. polynomials
  1487. legendre : Legendre polynomial object
  1488. hyp2f1 : Gauss hypergeometric function
  1489. numpy.polynomial.legendre.Legendre : Legendre series
  1490. """)
  1491. add_newdoc("scipy.special", "eval_sh_legendre",
  1492. r"""
  1493. eval_sh_legendre(n, x, out=None)
  1494. Evaluate shifted Legendre polynomial at a point.
  1495. These polynomials are defined as
  1496. .. math::
  1497. P_n^*(x) = P_n(2x - 1)
  1498. where :math:`P_n` is a Legendre polynomial.
  1499. Parameters
  1500. ----------
  1501. n : array_like
  1502. Degree of the polynomial. If not an integer, the value is
  1503. determined via the relation to `eval_legendre`.
  1504. x : array_like
  1505. Points at which to evaluate the shifted Legendre polynomial
  1506. Returns
  1507. -------
  1508. P : ndarray
  1509. Values of the shifted Legendre polynomial
  1510. See Also
  1511. --------
  1512. roots_sh_legendre : roots and quadrature weights of shifted
  1513. Legendre polynomials
  1514. sh_legendre : shifted Legendre polynomial object
  1515. eval_legendre : evaluate Legendre polynomials
  1516. numpy.polynomial.legendre.Legendre : Legendre series
  1517. """)
  1518. add_newdoc("scipy.special", "eval_genlaguerre",
  1519. r"""
  1520. eval_genlaguerre(n, alpha, x, out=None)
  1521. Evaluate generalized Laguerre polynomial at a point.
  1522. The generalized Laguerre polynomials can be defined via the
  1523. confluent hypergeometric function :math:`{}_1F_1` as
  1524. .. math::
  1525. L_n^{(\alpha)}(x) = \binom{n + \alpha}{n}
  1526. {}_1F_1(-n, \alpha + 1, x).
  1527. When :math:`n` is an integer the result is a polynomial of degree
  1528. :math:`n`. The Laguerre polynomials are the special case where
  1529. :math:`\alpha = 0`.
  1530. Parameters
  1531. ----------
  1532. n : array_like
  1533. Degree of the polynomial. If not an integer the result is
  1534. determined via the relation to the confluent hypergeometric
  1535. function.
  1536. alpha : array_like
  1537. Parameter; must have ``alpha > -1``
  1538. x : array_like
  1539. Points at which to evaluate the generalized Laguerre
  1540. polynomial
  1541. Returns
  1542. -------
  1543. L : ndarray
  1544. Values of the generalized Laguerre polynomial
  1545. See Also
  1546. --------
  1547. roots_genlaguerre : roots and quadrature weights of generalized
  1548. Laguerre polynomials
  1549. genlaguerre : generalized Laguerre polynomial object
  1550. hyp1f1 : confluent hypergeometric function
  1551. eval_laguerre : evaluate Laguerre polynomials
  1552. """)
  1553. add_newdoc("scipy.special", "eval_laguerre",
  1554. r"""
  1555. eval_laguerre(n, x, out=None)
  1556. Evaluate Laguerre polynomial at a point.
  1557. The Laguerre polynomials can be defined via the confluent
  1558. hypergeometric function :math:`{}_1F_1` as
  1559. .. math::
  1560. L_n(x) = {}_1F_1(-n, 1, x).
  1561. When :math:`n` is an integer the result is a polynomial of degree
  1562. :math:`n`.
  1563. Parameters
  1564. ----------
  1565. n : array_like
  1566. Degree of the polynomial. If not an integer the result is
  1567. determined via the relation to the confluent hypergeometric
  1568. function.
  1569. x : array_like
  1570. Points at which to evaluate the Laguerre polynomial
  1571. Returns
  1572. -------
  1573. L : ndarray
  1574. Values of the Laguerre polynomial
  1575. See Also
  1576. --------
  1577. roots_laguerre : roots and quadrature weights of Laguerre
  1578. polynomials
  1579. laguerre : Laguerre polynomial object
  1580. numpy.polynomial.laguerre.Laguerre : Laguerre series
  1581. eval_genlaguerre : evaluate generalized Laguerre polynomials
  1582. """)
  1583. add_newdoc("scipy.special", "eval_hermite",
  1584. r"""
  1585. eval_hermite(n, x, out=None)
  1586. Evaluate physicist's Hermite polynomial at a point.
  1587. Defined by
  1588. .. math::
  1589. H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2};
  1590. :math:`H_n` is a polynomial of degree :math:`n`.
  1591. Parameters
  1592. ----------
  1593. n : array_like
  1594. Degree of the polynomial
  1595. x : array_like
  1596. Points at which to evaluate the Hermite polynomial
  1597. Returns
  1598. -------
  1599. H : ndarray
  1600. Values of the Hermite polynomial
  1601. See Also
  1602. --------
  1603. roots_hermite : roots and quadrature weights of physicist's
  1604. Hermite polynomials
  1605. hermite : physicist's Hermite polynomial object
  1606. numpy.polynomial.hermite.Hermite : Physicist's Hermite series
  1607. eval_hermitenorm : evaluate Probabilist's Hermite polynomials
  1608. """)
  1609. add_newdoc("scipy.special", "eval_hermitenorm",
  1610. r"""
  1611. eval_hermitenorm(n, x, out=None)
  1612. Evaluate probabilist's (normalized) Hermite polynomial at a
  1613. point.
  1614. Defined by
  1615. .. math::
  1616. He_n(x) = (-1)^n e^{x^2/2} \frac{d^n}{dx^n} e^{-x^2/2};
  1617. :math:`He_n` is a polynomial of degree :math:`n`.
  1618. Parameters
  1619. ----------
  1620. n : array_like
  1621. Degree of the polynomial
  1622. x : array_like
  1623. Points at which to evaluate the Hermite polynomial
  1624. Returns
  1625. -------
  1626. He : ndarray
  1627. Values of the Hermite polynomial
  1628. See Also
  1629. --------
  1630. roots_hermitenorm : roots and quadrature weights of probabilist's
  1631. Hermite polynomials
  1632. hermitenorm : probabilist's Hermite polynomial object
  1633. numpy.polynomial.hermite_e.HermiteE : Probabilist's Hermite series
  1634. eval_hermite : evaluate physicist's Hermite polynomials
  1635. """)
  1636. add_newdoc("scipy.special", "exp1",
  1637. """
  1638. exp1(z)
  1639. Exponential integral E_1 of complex argument z
  1640. ::
  1641. integral(exp(-z*t)/t, t=1..inf).
  1642. """)
  1643. add_newdoc("scipy.special", "exp10",
  1644. """
  1645. exp10(x)
  1646. Compute ``10**x`` element-wise.
  1647. Parameters
  1648. ----------
  1649. x : array_like
  1650. `x` must contain real numbers.
  1651. Returns
  1652. -------
  1653. float
  1654. ``10**x``, computed element-wise.
  1655. Examples
  1656. --------
  1657. >>> from scipy.special import exp10
  1658. >>> exp10(3)
  1659. 1000.0
  1660. >>> x = np.array([[-1, -0.5, 0], [0.5, 1, 1.5]])
  1661. >>> exp10(x)
  1662. array([[ 0.1 , 0.31622777, 1. ],
  1663. [ 3.16227766, 10. , 31.6227766 ]])
  1664. """)
  1665. add_newdoc("scipy.special", "exp2",
  1666. """
  1667. exp2(x)
  1668. Compute ``2**x`` element-wise.
  1669. Parameters
  1670. ----------
  1671. x : array_like
  1672. `x` must contain real numbers.
  1673. Returns
  1674. -------
  1675. float
  1676. ``2**x``, computed element-wise.
  1677. Examples
  1678. --------
  1679. >>> from scipy.special import exp2
  1680. >>> exp2(3)
  1681. 8.0
  1682. >>> x = np.array([[-1, -0.5, 0], [0.5, 1, 1.5]])
  1683. >>> exp2(x)
  1684. array([[ 0.5 , 0.70710678, 1. ],
  1685. [ 1.41421356, 2. , 2.82842712]])
  1686. """)
  1687. add_newdoc("scipy.special", "expi",
  1688. """
  1689. expi(x)
  1690. Exponential integral Ei
  1691. Defined as::
  1692. integral(exp(t)/t, t=-inf..x)
  1693. See `expn` for a different exponential integral.
  1694. """)
  1695. add_newdoc('scipy.special', 'expit',
  1696. """
  1697. expit(x)
  1698. Expit (a.k.a. logistic sigmoid) ufunc for ndarrays.
  1699. The expit function, also known as the logistic sigmoid function, is
  1700. defined as ``expit(x) = 1/(1+exp(-x))``. It is the inverse of the
  1701. logit function.
  1702. Parameters
  1703. ----------
  1704. x : ndarray
  1705. The ndarray to apply expit to element-wise.
  1706. Returns
  1707. -------
  1708. out : ndarray
  1709. An ndarray of the same shape as x. Its entries
  1710. are `expit` of the corresponding entry of x.
  1711. See Also
  1712. --------
  1713. logit
  1714. Notes
  1715. -----
  1716. As a ufunc expit takes a number of optional
  1717. keyword arguments. For more information
  1718. see `ufuncs <https://docs.scipy.org/doc/numpy/reference/ufuncs.html>`_
  1719. .. versionadded:: 0.10.0
  1720. Examples
  1721. --------
  1722. >>> from scipy.special import expit, logit
  1723. >>> expit([-np.inf, -1.5, 0, 1.5, np.inf])
  1724. array([ 0. , 0.18242552, 0.5 , 0.81757448, 1. ])
  1725. `logit` is the inverse of `expit`:
  1726. >>> logit(expit([-2.5, 0, 3.1, 5.0]))
  1727. array([-2.5, 0. , 3.1, 5. ])
  1728. Plot expit(x) for x in [-6, 6]:
  1729. >>> import matplotlib.pyplot as plt
  1730. >>> x = np.linspace(-6, 6, 121)
  1731. >>> y = expit(x)
  1732. >>> plt.plot(x, y)
  1733. >>> plt.grid()
  1734. >>> plt.xlim(-6, 6)
  1735. >>> plt.xlabel('x')
  1736. >>> plt.title('expit(x)')
  1737. >>> plt.show()
  1738. """)
  1739. add_newdoc("scipy.special", "expm1",
  1740. """
  1741. expm1(x)
  1742. Compute ``exp(x) - 1``.
  1743. When `x` is near zero, ``exp(x)`` is near 1, so the numerical calculation
  1744. of ``exp(x) - 1`` can suffer from catastrophic loss of precision.
  1745. ``expm1(x)`` is implemented to avoid the loss of precision that occurs when
  1746. `x` is near zero.
  1747. Parameters
  1748. ----------
  1749. x : array_like
  1750. `x` must contain real numbers.
  1751. Returns
  1752. -------
  1753. float
  1754. ``exp(x) - 1`` computed element-wise.
  1755. Examples
  1756. --------
  1757. >>> from scipy.special import expm1
  1758. >>> expm1(1.0)
  1759. 1.7182818284590451
  1760. >>> expm1([-0.2, -0.1, 0, 0.1, 0.2])
  1761. array([-0.18126925, -0.09516258, 0. , 0.10517092, 0.22140276])
  1762. The exact value of ``exp(7.5e-13) - 1`` is::
  1763. 7.5000000000028125000000007031250000001318...*10**-13.
  1764. Here is what ``expm1(7.5e-13)`` gives:
  1765. >>> expm1(7.5e-13)
  1766. 7.5000000000028135e-13
  1767. Compare that to ``exp(7.5e-13) - 1``, where the subtraction results in
  1768. a "catastrophic" loss of precision:
  1769. >>> np.exp(7.5e-13) - 1
  1770. 7.5006667543675576e-13
  1771. """)
  1772. add_newdoc("scipy.special", "expn",
  1773. """
  1774. expn(n, x)
  1775. Exponential integral E_n
  1776. Returns the exponential integral for integer `n` and non-negative `x` and
  1777. `n`::
  1778. integral(exp(-x*t) / t**n, t=1..inf).
  1779. """)
  1780. add_newdoc("scipy.special", "exprel",
  1781. r"""
  1782. exprel(x)
  1783. Relative error exponential, ``(exp(x) - 1)/x``.
  1784. When `x` is near zero, ``exp(x)`` is near 1, so the numerical calculation
  1785. of ``exp(x) - 1`` can suffer from catastrophic loss of precision.
  1786. ``exprel(x)`` is implemented to avoid the loss of precision that occurs when
  1787. `x` is near zero.
  1788. Parameters
  1789. ----------
  1790. x : ndarray
  1791. Input array. `x` must contain real numbers.
  1792. Returns
  1793. -------
  1794. float
  1795. ``(exp(x) - 1)/x``, computed element-wise.
  1796. See Also
  1797. --------
  1798. expm1
  1799. Notes
  1800. -----
  1801. .. versionadded:: 0.17.0
  1802. Examples
  1803. --------
  1804. >>> from scipy.special import exprel
  1805. >>> exprel(0.01)
  1806. 1.0050167084168056
  1807. >>> exprel([-0.25, -0.1, 0, 0.1, 0.25])
  1808. array([ 0.88479687, 0.95162582, 1. , 1.05170918, 1.13610167])
  1809. Compare ``exprel(5e-9)`` to the naive calculation. The exact value
  1810. is ``1.00000000250000000416...``.
  1811. >>> exprel(5e-9)
  1812. 1.0000000025
  1813. >>> (np.exp(5e-9) - 1)/5e-9
  1814. 0.99999999392252903
  1815. """)
  1816. add_newdoc("scipy.special", "fdtr",
  1817. r"""
  1818. fdtr(dfn, dfd, x)
  1819. F cumulative distribution function.
  1820. Returns the value of the cumulative density function of the
  1821. F-distribution, also known as Snedecor's F-distribution or the
  1822. Fisher-Snedecor distribution.
  1823. The F-distribution with parameters :math:`d_n` and :math:`d_d` is the
  1824. distribution of the random variable,
  1825. .. math::
  1826. X = \frac{U_n/d_n}{U_d/d_d},
  1827. where :math:`U_n` and :math:`U_d` are random variables distributed
  1828. :math:`\chi^2`, with :math:`d_n` and :math:`d_d` degrees of freedom,
  1829. respectively.
  1830. Parameters
  1831. ----------
  1832. dfn : array_like
  1833. First parameter (positive float).
  1834. dfd : array_like
  1835. Second parameter (positive float).
  1836. x : array_like
  1837. Argument (nonnegative float).
  1838. Returns
  1839. -------
  1840. y : ndarray
  1841. The CDF of the F-distribution with parameters `dfn` and `dfd` at `x`.
  1842. Notes
  1843. -----
  1844. The regularized incomplete beta function is used, according to the
  1845. formula,
  1846. .. math::
  1847. F(d_n, d_d; x) = I_{xd_n/(d_d + xd_n)}(d_n/2, d_d/2).
  1848. Wrapper for the Cephes [1]_ routine `fdtr`.
  1849. References
  1850. ----------
  1851. .. [1] Cephes Mathematical Functions Library,
  1852. http://www.netlib.org/cephes/
  1853. """)
  1854. add_newdoc("scipy.special", "fdtrc",
  1855. r"""
  1856. fdtrc(dfn, dfd, x)
  1857. F survival function.
  1858. Returns the complemented F-distribution function (the integral of the
  1859. density from `x` to infinity).
  1860. Parameters
  1861. ----------
  1862. dfn : array_like
  1863. First parameter (positive float).
  1864. dfd : array_like
  1865. Second parameter (positive float).
  1866. x : array_like
  1867. Argument (nonnegative float).
  1868. Returns
  1869. -------
  1870. y : ndarray
  1871. The complemented F-distribution function with parameters `dfn` and
  1872. `dfd` at `x`.
  1873. See also
  1874. --------
  1875. fdtr
  1876. Notes
  1877. -----
  1878. The regularized incomplete beta function is used, according to the
  1879. formula,
  1880. .. math::
  1881. F(d_n, d_d; x) = I_{d_d/(d_d + xd_n)}(d_d/2, d_n/2).
  1882. Wrapper for the Cephes [1]_ routine `fdtrc`.
  1883. References
  1884. ----------
  1885. .. [1] Cephes Mathematical Functions Library,
  1886. http://www.netlib.org/cephes/
  1887. """)
  1888. add_newdoc("scipy.special", "fdtri",
  1889. r"""
  1890. fdtri(dfn, dfd, p)
  1891. The `p`-th quantile of the F-distribution.
  1892. This function is the inverse of the F-distribution CDF, `fdtr`, returning
  1893. the `x` such that `fdtr(dfn, dfd, x) = p`.
  1894. Parameters
  1895. ----------
  1896. dfn : array_like
  1897. First parameter (positive float).
  1898. dfd : array_like
  1899. Second parameter (positive float).
  1900. p : array_like
  1901. Cumulative probability, in [0, 1].
  1902. Returns
  1903. -------
  1904. x : ndarray
  1905. The quantile corresponding to `p`.
  1906. Notes
  1907. -----
  1908. The computation is carried out using the relation to the inverse
  1909. regularized beta function, :math:`I^{-1}_x(a, b)`. Let
  1910. :math:`z = I^{-1}_p(d_d/2, d_n/2).` Then,
  1911. .. math::
  1912. x = \frac{d_d (1 - z)}{d_n z}.
  1913. If `p` is such that :math:`x < 0.5`, the following relation is used
  1914. instead for improved stability: let
  1915. :math:`z' = I^{-1}_{1 - p}(d_n/2, d_d/2).` Then,
  1916. .. math::
  1917. x = \frac{d_d z'}{d_n (1 - z')}.
  1918. Wrapper for the Cephes [1]_ routine `fdtri`.
  1919. References
  1920. ----------
  1921. .. [1] Cephes Mathematical Functions Library,
  1922. http://www.netlib.org/cephes/
  1923. """)
  1924. add_newdoc("scipy.special", "fdtridfd",
  1925. """
  1926. fdtridfd(dfn, p, x)
  1927. Inverse to `fdtr` vs dfd
  1928. Finds the F density argument dfd such that ``fdtr(dfn, dfd, x) == p``.
  1929. """)
  1930. add_newdoc("scipy.special", "fdtridfn",
  1931. """
  1932. fdtridfn(p, dfd, x)
  1933. Inverse to `fdtr` vs dfn
  1934. finds the F density argument dfn such that ``fdtr(dfn, dfd, x) == p``.
  1935. """)
  1936. add_newdoc("scipy.special", "fresnel",
  1937. """
  1938. fresnel(z)
  1939. Fresnel sin and cos integrals
  1940. Defined as::
  1941. ssa = integral(sin(pi/2 * t**2), t=0..z)
  1942. csa = integral(cos(pi/2 * t**2), t=0..z)
  1943. Parameters
  1944. ----------
  1945. z : float or complex array_like
  1946. Argument
  1947. Returns
  1948. -------
  1949. ssa, csa
  1950. Fresnel sin and cos integral values
  1951. """)
  1952. add_newdoc("scipy.special", "gamma",
  1953. r"""
  1954. gamma(z)
  1955. Gamma function.
  1956. .. math::
  1957. \Gamma(z) = \int_0^\infty x^{z-1} e^{-x} dx = (z - 1)!
  1958. The gamma function is often referred to as the generalized
  1959. factorial since ``z*gamma(z) = gamma(z+1)`` and ``gamma(n+1) =
  1960. n!`` for natural number *n*.
  1961. Parameters
  1962. ----------
  1963. z : float or complex array_like
  1964. Returns
  1965. -------
  1966. float or complex
  1967. The value(s) of gamma(z)
  1968. Examples
  1969. --------
  1970. >>> from scipy.special import gamma, factorial
  1971. >>> gamma([0, 0.5, 1, 5])
  1972. array([ inf, 1.77245385, 1. , 24. ])
  1973. >>> z = 2.5 + 1j
  1974. >>> gamma(z)
  1975. (0.77476210455108352+0.70763120437959293j)
  1976. >>> gamma(z+1), z*gamma(z) # Recurrence property
  1977. ((1.2292740569981171+2.5438401155000685j),
  1978. (1.2292740569981158+2.5438401155000658j))
  1979. >>> gamma(0.5)**2 # gamma(0.5) = sqrt(pi)
  1980. 3.1415926535897927
  1981. Plot gamma(x) for real x
  1982. >>> x = np.linspace(-3.5, 5.5, 2251)
  1983. >>> y = gamma(x)
  1984. >>> import matplotlib.pyplot as plt
  1985. >>> plt.plot(x, y, 'b', alpha=0.6, label='gamma(x)')
  1986. >>> k = np.arange(1, 7)
  1987. >>> plt.plot(k, factorial(k-1), 'k*', alpha=0.6,
  1988. ... label='(x-1)!, x = 1, 2, ...')
  1989. >>> plt.xlim(-3.5, 5.5)
  1990. >>> plt.ylim(-10, 25)
  1991. >>> plt.grid()
  1992. >>> plt.xlabel('x')
  1993. >>> plt.legend(loc='lower right')
  1994. >>> plt.show()
  1995. """)
  1996. add_newdoc("scipy.special", "gammainc",
  1997. r"""
  1998. gammainc(a, x)
  1999. Regularized lower incomplete gamma function.
  2000. Defined as
  2001. .. math::
  2002. \frac{1}{\Gamma(a)} \int_0^x t^{a - 1}e^{-t} dt
  2003. for :math:`a > 0` and :math:`x \geq 0`. The function satisfies the
  2004. relation ``gammainc(a, x) + gammaincc(a, x) = 1`` where
  2005. `gammaincc` is the regularized upper incomplete gamma function.
  2006. Notes
  2007. -----
  2008. The implementation largely follows that of [1]_.
  2009. See also
  2010. --------
  2011. gammaincc : regularized upper incomplete gamma function
  2012. gammaincinv : inverse to ``gammainc`` versus ``x``
  2013. gammainccinv : inverse to ``gammaincc`` versus ``x``
  2014. References
  2015. ----------
  2016. .. [1] Maddock et. al., "Incomplete Gamma Functions",
  2017. https://www.boost.org/doc/libs/1_61_0/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html
  2018. """)
  2019. add_newdoc("scipy.special", "gammaincc",
  2020. r"""
  2021. gammaincc(a, x)
  2022. Regularized upper incomplete gamma function.
  2023. Defined as
  2024. .. math::
  2025. \frac{1}{\Gamma(a)} \int_x^\infty t^{a - 1}e^{-t} dt
  2026. for :math:`a > 0` and :math:`x \geq 0`. The function satisfies the
  2027. relation ``gammainc(a, x) + gammaincc(a, x) = 1`` where `gammainc`
  2028. is the regularized lower incomplete gamma function.
  2029. Notes
  2030. -----
  2031. The implementation largely follows that of [1]_.
  2032. See also
  2033. --------
  2034. gammainc : regularized lower incomplete gamma function
  2035. gammaincinv : inverse to ``gammainc`` versus ``x``
  2036. gammainccinv : inverse to ``gammaincc`` versus ``x``
  2037. References
  2038. ----------
  2039. .. [1] Maddock et. al., "Incomplete Gamma Functions",
  2040. https://www.boost.org/doc/libs/1_61_0/libs/math/doc/html/math_toolkit/sf_gamma/igamma.html
  2041. """)
  2042. add_newdoc("scipy.special", "gammainccinv",
  2043. """
  2044. gammainccinv(a, y)
  2045. Inverse to `gammaincc`
  2046. Returns `x` such that ``gammaincc(a, x) == y``.
  2047. """)
  2048. add_newdoc("scipy.special", "gammaincinv",
  2049. """
  2050. gammaincinv(a, y)
  2051. Inverse to `gammainc`
  2052. Returns `x` such that ``gammainc(a, x) = y``.
  2053. """)
  2054. add_newdoc("scipy.special", "gammaln",
  2055. """
  2056. Logarithm of the absolute value of the Gamma function.
  2057. Parameters
  2058. ----------
  2059. x : array-like
  2060. Values on the real line at which to compute ``gammaln``
  2061. Returns
  2062. -------
  2063. gammaln : ndarray
  2064. Values of ``gammaln`` at x.
  2065. See Also
  2066. --------
  2067. gammasgn : sign of the gamma function
  2068. loggamma : principal branch of the logarithm of the gamma function
  2069. Notes
  2070. -----
  2071. When used in conjunction with `gammasgn`, this function is useful
  2072. for working in logspace on the real axis without having to deal with
  2073. complex numbers, via the relation ``exp(gammaln(x)) = gammasgn(x)*gamma(x)``.
  2074. For complex-valued log-gamma, use `loggamma` instead of `gammaln`.
  2075. """)
  2076. add_newdoc("scipy.special", "gammasgn",
  2077. """
  2078. gammasgn(x)
  2079. Sign of the gamma function.
  2080. See Also
  2081. --------
  2082. gammaln
  2083. loggamma
  2084. """)
  2085. add_newdoc("scipy.special", "gdtr",
  2086. r"""
  2087. gdtr(a, b, x)
  2088. Gamma distribution cumulative density function.
  2089. Returns the integral from zero to `x` of the gamma probability density
  2090. function,
  2091. .. math::
  2092. F = \int_0^x \frac{a^b}{\Gamma(b)} t^{b-1} e^{-at}\,dt,
  2093. where :math:`\Gamma` is the gamma function.
  2094. Parameters
  2095. ----------
  2096. a : array_like
  2097. The rate parameter of the gamma distribution, sometimes denoted
  2098. :math:`\beta` (float). It is also the reciprocal of the scale
  2099. parameter :math:`\theta`.
  2100. b : array_like
  2101. The shape parameter of the gamma distribution, sometimes denoted
  2102. :math:`\alpha` (float).
  2103. x : array_like
  2104. The quantile (upper limit of integration; float).
  2105. See also
  2106. --------
  2107. gdtrc : 1 - CDF of the gamma distribution.
  2108. Returns
  2109. -------
  2110. F : ndarray
  2111. The CDF of the gamma distribution with parameters `a` and `b`
  2112. evaluated at `x`.
  2113. Notes
  2114. -----
  2115. The evaluation is carried out using the relation to the incomplete gamma
  2116. integral (regularized gamma function).
  2117. Wrapper for the Cephes [1]_ routine `gdtr`.
  2118. References
  2119. ----------
  2120. .. [1] Cephes Mathematical Functions Library,
  2121. http://www.netlib.org/cephes/
  2122. """)
  2123. add_newdoc("scipy.special", "gdtrc",
  2124. r"""
  2125. gdtrc(a, b, x)
  2126. Gamma distribution survival function.
  2127. Integral from `x` to infinity of the gamma probability density function,
  2128. .. math::
  2129. F = \int_x^\infty \frac{a^b}{\Gamma(b)} t^{b-1} e^{-at}\,dt,
  2130. where :math:`\Gamma` is the gamma function.
  2131. Parameters
  2132. ----------
  2133. a : array_like
  2134. The rate parameter of the gamma distribution, sometimes denoted
  2135. :math:`\beta` (float). It is also the reciprocal of the scale
  2136. parameter :math:`\theta`.
  2137. b : array_like
  2138. The shape parameter of the gamma distribution, sometimes denoted
  2139. :math:`\alpha` (float).
  2140. x : array_like
  2141. The quantile (lower limit of integration; float).
  2142. Returns
  2143. -------
  2144. F : ndarray
  2145. The survival function of the gamma distribution with parameters `a`
  2146. and `b` evaluated at `x`.
  2147. See Also
  2148. --------
  2149. gdtr, gdtrix
  2150. Notes
  2151. -----
  2152. The evaluation is carried out using the relation to the incomplete gamma
  2153. integral (regularized gamma function).
  2154. Wrapper for the Cephes [1]_ routine `gdtrc`.
  2155. References
  2156. ----------
  2157. .. [1] Cephes Mathematical Functions Library,
  2158. http://www.netlib.org/cephes/
  2159. """)
  2160. add_newdoc("scipy.special", "gdtria",
  2161. """
  2162. gdtria(p, b, x, out=None)
  2163. Inverse of `gdtr` vs a.
  2164. Returns the inverse with respect to the parameter `a` of ``p =
  2165. gdtr(a, b, x)``, the cumulative distribution function of the gamma
  2166. distribution.
  2167. Parameters
  2168. ----------
  2169. p : array_like
  2170. Probability values.
  2171. b : array_like
  2172. `b` parameter values of `gdtr(a, b, x)`. `b` is the "shape" parameter
  2173. of the gamma distribution.
  2174. x : array_like
  2175. Nonnegative real values, from the domain of the gamma distribution.
  2176. out : ndarray, optional
  2177. If a fourth argument is given, it must be a numpy.ndarray whose size
  2178. matches the broadcast result of `a`, `b` and `x`. `out` is then the
  2179. array returned by the function.
  2180. Returns
  2181. -------
  2182. a : ndarray
  2183. Values of the `a` parameter such that `p = gdtr(a, b, x)`. `1/a`
  2184. is the "scale" parameter of the gamma distribution.
  2185. See Also
  2186. --------
  2187. gdtr : CDF of the gamma distribution.
  2188. gdtrib : Inverse with respect to `b` of `gdtr(a, b, x)`.
  2189. gdtrix : Inverse with respect to `x` of `gdtr(a, b, x)`.
  2190. Notes
  2191. -----
  2192. Wrapper for the CDFLIB [1]_ Fortran routine `cdfgam`.
  2193. The cumulative distribution function `p` is computed using a routine by
  2194. DiDinato and Morris [2]_. Computation of `a` involves a search for a value
  2195. that produces the desired value of `p`. The search relies on the
  2196. monotonicity of `p` with `a`.
  2197. References
  2198. ----------
  2199. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  2200. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  2201. Functions, Inverses, and Other Parameters.
  2202. .. [2] DiDinato, A. R. and Morris, A. H.,
  2203. Computation of the incomplete gamma function ratios and their
  2204. inverse. ACM Trans. Math. Softw. 12 (1986), 377-393.
  2205. Examples
  2206. --------
  2207. First evaluate `gdtr`.
  2208. >>> from scipy.special import gdtr, gdtria
  2209. >>> p = gdtr(1.2, 3.4, 5.6)
  2210. >>> print(p)
  2211. 0.94378087442
  2212. Verify the inverse.
  2213. >>> gdtria(p, 3.4, 5.6)
  2214. 1.2
  2215. """)
  2216. add_newdoc("scipy.special", "gdtrib",
  2217. """
  2218. gdtrib(a, p, x, out=None)
  2219. Inverse of `gdtr` vs b.
  2220. Returns the inverse with respect to the parameter `b` of ``p =
  2221. gdtr(a, b, x)``, the cumulative distribution function of the gamma
  2222. distribution.
  2223. Parameters
  2224. ----------
  2225. a : array_like
  2226. `a` parameter values of `gdtr(a, b, x)`. `1/a` is the "scale"
  2227. parameter of the gamma distribution.
  2228. p : array_like
  2229. Probability values.
  2230. x : array_like
  2231. Nonnegative real values, from the domain of the gamma distribution.
  2232. out : ndarray, optional
  2233. If a fourth argument is given, it must be a numpy.ndarray whose size
  2234. matches the broadcast result of `a`, `b` and `x`. `out` is then the
  2235. array returned by the function.
  2236. Returns
  2237. -------
  2238. b : ndarray
  2239. Values of the `b` parameter such that `p = gdtr(a, b, x)`. `b` is
  2240. the "shape" parameter of the gamma distribution.
  2241. See Also
  2242. --------
  2243. gdtr : CDF of the gamma distribution.
  2244. gdtria : Inverse with respect to `a` of `gdtr(a, b, x)`.
  2245. gdtrix : Inverse with respect to `x` of `gdtr(a, b, x)`.
  2246. Notes
  2247. -----
  2248. Wrapper for the CDFLIB [1]_ Fortran routine `cdfgam`.
  2249. The cumulative distribution function `p` is computed using a routine by
  2250. DiDinato and Morris [2]_. Computation of `b` involves a search for a value
  2251. that produces the desired value of `p`. The search relies on the
  2252. monotonicity of `p` with `b`.
  2253. References
  2254. ----------
  2255. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  2256. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  2257. Functions, Inverses, and Other Parameters.
  2258. .. [2] DiDinato, A. R. and Morris, A. H.,
  2259. Computation of the incomplete gamma function ratios and their
  2260. inverse. ACM Trans. Math. Softw. 12 (1986), 377-393.
  2261. Examples
  2262. --------
  2263. First evaluate `gdtr`.
  2264. >>> from scipy.special import gdtr, gdtrib
  2265. >>> p = gdtr(1.2, 3.4, 5.6)
  2266. >>> print(p)
  2267. 0.94378087442
  2268. Verify the inverse.
  2269. >>> gdtrib(1.2, p, 5.6)
  2270. 3.3999999999723882
  2271. """)
  2272. add_newdoc("scipy.special", "gdtrix",
  2273. """
  2274. gdtrix(a, b, p, out=None)
  2275. Inverse of `gdtr` vs x.
  2276. Returns the inverse with respect to the parameter `x` of ``p =
  2277. gdtr(a, b, x)``, the cumulative distribution function of the gamma
  2278. distribution. This is also known as the p'th quantile of the
  2279. distribution.
  2280. Parameters
  2281. ----------
  2282. a : array_like
  2283. `a` parameter values of `gdtr(a, b, x)`. `1/a` is the "scale"
  2284. parameter of the gamma distribution.
  2285. b : array_like
  2286. `b` parameter values of `gdtr(a, b, x)`. `b` is the "shape" parameter
  2287. of the gamma distribution.
  2288. p : array_like
  2289. Probability values.
  2290. out : ndarray, optional
  2291. If a fourth argument is given, it must be a numpy.ndarray whose size
  2292. matches the broadcast result of `a`, `b` and `x`. `out` is then the
  2293. array returned by the function.
  2294. Returns
  2295. -------
  2296. x : ndarray
  2297. Values of the `x` parameter such that `p = gdtr(a, b, x)`.
  2298. See Also
  2299. --------
  2300. gdtr : CDF of the gamma distribution.
  2301. gdtria : Inverse with respect to `a` of `gdtr(a, b, x)`.
  2302. gdtrib : Inverse with respect to `b` of `gdtr(a, b, x)`.
  2303. Notes
  2304. -----
  2305. Wrapper for the CDFLIB [1]_ Fortran routine `cdfgam`.
  2306. The cumulative distribution function `p` is computed using a routine by
  2307. DiDinato and Morris [2]_. Computation of `x` involves a search for a value
  2308. that produces the desired value of `p`. The search relies on the
  2309. monotonicity of `p` with `x`.
  2310. References
  2311. ----------
  2312. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  2313. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  2314. Functions, Inverses, and Other Parameters.
  2315. .. [2] DiDinato, A. R. and Morris, A. H.,
  2316. Computation of the incomplete gamma function ratios and their
  2317. inverse. ACM Trans. Math. Softw. 12 (1986), 377-393.
  2318. Examples
  2319. --------
  2320. First evaluate `gdtr`.
  2321. >>> from scipy.special import gdtr, gdtrix
  2322. >>> p = gdtr(1.2, 3.4, 5.6)
  2323. >>> print(p)
  2324. 0.94378087442
  2325. Verify the inverse.
  2326. >>> gdtrix(1.2, 3.4, p)
  2327. 5.5999999999999996
  2328. """)
  2329. add_newdoc("scipy.special", "hankel1",
  2330. r"""
  2331. hankel1(v, z)
  2332. Hankel function of the first kind
  2333. Parameters
  2334. ----------
  2335. v : array_like
  2336. Order (float).
  2337. z : array_like
  2338. Argument (float or complex).
  2339. Returns
  2340. -------
  2341. out : Values of the Hankel function of the first kind.
  2342. Notes
  2343. -----
  2344. A wrapper for the AMOS [1]_ routine `zbesh`, which carries out the
  2345. computation using the relation,
  2346. .. math:: H^{(1)}_v(z) = \frac{2}{\imath\pi} \exp(-\imath \pi v/2) K_v(z \exp(-\imath\pi/2))
  2347. where :math:`K_v` is the modified Bessel function of the second kind.
  2348. For negative orders, the relation
  2349. .. math:: H^{(1)}_{-v}(z) = H^{(1)}_v(z) \exp(\imath\pi v)
  2350. is used.
  2351. See also
  2352. --------
  2353. hankel1e : this function with leading exponential behavior stripped off.
  2354. References
  2355. ----------
  2356. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  2357. of a Complex Argument and Nonnegative Order",
  2358. http://netlib.org/amos/
  2359. """)
  2360. add_newdoc("scipy.special", "hankel1e",
  2361. r"""
  2362. hankel1e(v, z)
  2363. Exponentially scaled Hankel function of the first kind
  2364. Defined as::
  2365. hankel1e(v, z) = hankel1(v, z) * exp(-1j * z)
  2366. Parameters
  2367. ----------
  2368. v : array_like
  2369. Order (float).
  2370. z : array_like
  2371. Argument (float or complex).
  2372. Returns
  2373. -------
  2374. out : Values of the exponentially scaled Hankel function.
  2375. Notes
  2376. -----
  2377. A wrapper for the AMOS [1]_ routine `zbesh`, which carries out the
  2378. computation using the relation,
  2379. .. math:: H^{(1)}_v(z) = \frac{2}{\imath\pi} \exp(-\imath \pi v/2) K_v(z \exp(-\imath\pi/2))
  2380. where :math:`K_v` is the modified Bessel function of the second kind.
  2381. For negative orders, the relation
  2382. .. math:: H^{(1)}_{-v}(z) = H^{(1)}_v(z) \exp(\imath\pi v)
  2383. is used.
  2384. References
  2385. ----------
  2386. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  2387. of a Complex Argument and Nonnegative Order",
  2388. http://netlib.org/amos/
  2389. """)
  2390. add_newdoc("scipy.special", "hankel2",
  2391. r"""
  2392. hankel2(v, z)
  2393. Hankel function of the second kind
  2394. Parameters
  2395. ----------
  2396. v : array_like
  2397. Order (float).
  2398. z : array_like
  2399. Argument (float or complex).
  2400. Returns
  2401. -------
  2402. out : Values of the Hankel function of the second kind.
  2403. Notes
  2404. -----
  2405. A wrapper for the AMOS [1]_ routine `zbesh`, which carries out the
  2406. computation using the relation,
  2407. .. math:: H^{(2)}_v(z) = -\frac{2}{\imath\pi} \exp(\imath \pi v/2) K_v(z \exp(\imath\pi/2))
  2408. where :math:`K_v` is the modified Bessel function of the second kind.
  2409. For negative orders, the relation
  2410. .. math:: H^{(2)}_{-v}(z) = H^{(2)}_v(z) \exp(-\imath\pi v)
  2411. is used.
  2412. See also
  2413. --------
  2414. hankel2e : this function with leading exponential behavior stripped off.
  2415. References
  2416. ----------
  2417. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  2418. of a Complex Argument and Nonnegative Order",
  2419. http://netlib.org/amos/
  2420. """)
  2421. add_newdoc("scipy.special", "hankel2e",
  2422. r"""
  2423. hankel2e(v, z)
  2424. Exponentially scaled Hankel function of the second kind
  2425. Defined as::
  2426. hankel2e(v, z) = hankel2(v, z) * exp(1j * z)
  2427. Parameters
  2428. ----------
  2429. v : array_like
  2430. Order (float).
  2431. z : array_like
  2432. Argument (float or complex).
  2433. Returns
  2434. -------
  2435. out : Values of the exponentially scaled Hankel function of the second kind.
  2436. Notes
  2437. -----
  2438. A wrapper for the AMOS [1]_ routine `zbesh`, which carries out the
  2439. computation using the relation,
  2440. .. math:: H^{(2)}_v(z) = -\frac{2}{\imath\pi} \exp(\frac{\imath \pi v}{2}) K_v(z exp(\frac{\imath\pi}{2}))
  2441. where :math:`K_v` is the modified Bessel function of the second kind.
  2442. For negative orders, the relation
  2443. .. math:: H^{(2)}_{-v}(z) = H^{(2)}_v(z) \exp(-\imath\pi v)
  2444. is used.
  2445. References
  2446. ----------
  2447. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  2448. of a Complex Argument and Nonnegative Order",
  2449. http://netlib.org/amos/
  2450. """)
  2451. add_newdoc("scipy.special", "huber",
  2452. r"""
  2453. huber(delta, r)
  2454. Huber loss function.
  2455. .. math:: \text{huber}(\delta, r) = \begin{cases} \infty & \delta < 0 \\ \frac{1}{2}r^2 & 0 \le \delta, | r | \le \delta \\ \delta ( |r| - \frac{1}{2}\delta ) & \text{otherwise} \end{cases}
  2456. Parameters
  2457. ----------
  2458. delta : ndarray
  2459. Input array, indicating the quadratic vs. linear loss changepoint.
  2460. r : ndarray
  2461. Input array, possibly representing residuals.
  2462. Returns
  2463. -------
  2464. res : ndarray
  2465. The computed Huber loss function values.
  2466. Notes
  2467. -----
  2468. This function is convex in r.
  2469. .. versionadded:: 0.15.0
  2470. """)
  2471. add_newdoc("scipy.special", "hyp0f1",
  2472. r"""
  2473. hyp0f1(v, x)
  2474. Confluent hypergeometric limit function 0F1.
  2475. Parameters
  2476. ----------
  2477. v, z : array_like
  2478. Input values.
  2479. Returns
  2480. -------
  2481. hyp0f1 : ndarray
  2482. The confluent hypergeometric limit function.
  2483. Notes
  2484. -----
  2485. This function is defined as:
  2486. .. math:: _0F_1(v, z) = \sum_{k=0}^{\infty}\frac{z^k}{(v)_k k!}.
  2487. It's also the limit as :math:`q \to \infty` of :math:`_1F_1(q; v; z/q)`,
  2488. and satisfies the differential equation :math:`f''(z) + vf'(z) = f(z)`.
  2489. """)
  2490. add_newdoc("scipy.special", "hyp1f1",
  2491. """
  2492. hyp1f1(a, b, x)
  2493. Confluent hypergeometric function 1F1(a, b; x)
  2494. """)
  2495. add_newdoc("scipy.special", "hyp1f2",
  2496. """
  2497. hyp1f2(a, b, c, x)
  2498. Hypergeometric function 1F2 and error estimate
  2499. Returns
  2500. -------
  2501. y
  2502. Value of the function
  2503. err
  2504. Error estimate
  2505. """)
  2506. add_newdoc("scipy.special", "hyp2f0",
  2507. """
  2508. hyp2f0(a, b, x, type)
  2509. Hypergeometric function 2F0 in y and an error estimate
  2510. The parameter `type` determines a convergence factor and can be
  2511. either 1 or 2.
  2512. Returns
  2513. -------
  2514. y
  2515. Value of the function
  2516. err
  2517. Error estimate
  2518. """)
  2519. add_newdoc("scipy.special", "hyp2f1",
  2520. r"""
  2521. hyp2f1(a, b, c, z)
  2522. Gauss hypergeometric function 2F1(a, b; c; z)
  2523. Parameters
  2524. ----------
  2525. a, b, c : array_like
  2526. Arguments, should be real-valued.
  2527. z : array_like
  2528. Argument, real or complex.
  2529. Returns
  2530. -------
  2531. hyp2f1 : scalar or ndarray
  2532. The values of the gaussian hypergeometric function.
  2533. See also
  2534. --------
  2535. hyp0f1 : confluent hypergeometric limit function.
  2536. hyp1f1 : Kummer's (confluent hypergeometric) function.
  2537. Notes
  2538. -----
  2539. This function is defined for :math:`|z| < 1` as
  2540. .. math::
  2541. \mathrm{hyp2f1}(a, b, c, z) = \sum_{n=0}^\infty
  2542. \frac{(a)_n (b)_n}{(c)_n}\frac{z^n}{n!},
  2543. and defined on the rest of the complex z-plane by analytic continuation.
  2544. Here :math:`(\cdot)_n` is the Pochhammer symbol; see `poch`. When
  2545. :math:`n` is an integer the result is a polynomial of degree :math:`n`.
  2546. The implementation for complex values of ``z`` is described in [1]_.
  2547. References
  2548. ----------
  2549. .. [1] S. Zhang and J.M. Jin, "Computation of Special Functions", Wiley 1996
  2550. .. [2] Cephes Mathematical Functions Library,
  2551. http://www.netlib.org/cephes/
  2552. .. [3] NIST Digital Library of Mathematical Functions
  2553. https://dlmf.nist.gov/
  2554. """)
  2555. add_newdoc("scipy.special", "hyp3f0",
  2556. """
  2557. hyp3f0(a, b, c, x)
  2558. Hypergeometric function 3F0 in y and an error estimate
  2559. Returns
  2560. -------
  2561. y
  2562. Value of the function
  2563. err
  2564. Error estimate
  2565. """)
  2566. add_newdoc("scipy.special", "hyperu",
  2567. """
  2568. hyperu(a, b, x)
  2569. Confluent hypergeometric function U(a, b, x) of the second kind
  2570. """)
  2571. add_newdoc("scipy.special", "i0",
  2572. r"""
  2573. i0(x)
  2574. Modified Bessel function of order 0.
  2575. Defined as,
  2576. .. math::
  2577. I_0(x) = \sum_{k=0}^\infty \frac{(x^2/4)^k}{(k!)^2} = J_0(\imath x),
  2578. where :math:`J_0` is the Bessel function of the first kind of order 0.
  2579. Parameters
  2580. ----------
  2581. x : array_like
  2582. Argument (float)
  2583. Returns
  2584. -------
  2585. I : ndarray
  2586. Value of the modified Bessel function of order 0 at `x`.
  2587. Notes
  2588. -----
  2589. The range is partitioned into the two intervals [0, 8] and (8, infinity).
  2590. Chebyshev polynomial expansions are employed in each interval.
  2591. This function is a wrapper for the Cephes [1]_ routine `i0`.
  2592. See also
  2593. --------
  2594. iv
  2595. i0e
  2596. References
  2597. ----------
  2598. .. [1] Cephes Mathematical Functions Library,
  2599. http://www.netlib.org/cephes/
  2600. """)
  2601. add_newdoc("scipy.special", "i0e",
  2602. """
  2603. i0e(x)
  2604. Exponentially scaled modified Bessel function of order 0.
  2605. Defined as::
  2606. i0e(x) = exp(-abs(x)) * i0(x).
  2607. Parameters
  2608. ----------
  2609. x : array_like
  2610. Argument (float)
  2611. Returns
  2612. -------
  2613. I : ndarray
  2614. Value of the exponentially scaled modified Bessel function of order 0
  2615. at `x`.
  2616. Notes
  2617. -----
  2618. The range is partitioned into the two intervals [0, 8] and (8, infinity).
  2619. Chebyshev polynomial expansions are employed in each interval. The
  2620. polynomial expansions used are the same as those in `i0`, but
  2621. they are not multiplied by the dominant exponential factor.
  2622. This function is a wrapper for the Cephes [1]_ routine `i0e`.
  2623. See also
  2624. --------
  2625. iv
  2626. i0
  2627. References
  2628. ----------
  2629. .. [1] Cephes Mathematical Functions Library,
  2630. http://www.netlib.org/cephes/
  2631. """)
  2632. add_newdoc("scipy.special", "i1",
  2633. r"""
  2634. i1(x)
  2635. Modified Bessel function of order 1.
  2636. Defined as,
  2637. .. math::
  2638. I_1(x) = \frac{1}{2}x \sum_{k=0}^\infty \frac{(x^2/4)^k}{k! (k + 1)!}
  2639. = -\imath J_1(\imath x),
  2640. where :math:`J_1` is the Bessel function of the first kind of order 1.
  2641. Parameters
  2642. ----------
  2643. x : array_like
  2644. Argument (float)
  2645. Returns
  2646. -------
  2647. I : ndarray
  2648. Value of the modified Bessel function of order 1 at `x`.
  2649. Notes
  2650. -----
  2651. The range is partitioned into the two intervals [0, 8] and (8, infinity).
  2652. Chebyshev polynomial expansions are employed in each interval.
  2653. This function is a wrapper for the Cephes [1]_ routine `i1`.
  2654. See also
  2655. --------
  2656. iv
  2657. i1e
  2658. References
  2659. ----------
  2660. .. [1] Cephes Mathematical Functions Library,
  2661. http://www.netlib.org/cephes/
  2662. """)
  2663. add_newdoc("scipy.special", "i1e",
  2664. """
  2665. i1e(x)
  2666. Exponentially scaled modified Bessel function of order 1.
  2667. Defined as::
  2668. i1e(x) = exp(-abs(x)) * i1(x)
  2669. Parameters
  2670. ----------
  2671. x : array_like
  2672. Argument (float)
  2673. Returns
  2674. -------
  2675. I : ndarray
  2676. Value of the exponentially scaled modified Bessel function of order 1
  2677. at `x`.
  2678. Notes
  2679. -----
  2680. The range is partitioned into the two intervals [0, 8] and (8, infinity).
  2681. Chebyshev polynomial expansions are employed in each interval. The
  2682. polynomial expansions used are the same as those in `i1`, but
  2683. they are not multiplied by the dominant exponential factor.
  2684. This function is a wrapper for the Cephes [1]_ routine `i1e`.
  2685. See also
  2686. --------
  2687. iv
  2688. i1
  2689. References
  2690. ----------
  2691. .. [1] Cephes Mathematical Functions Library,
  2692. http://www.netlib.org/cephes/
  2693. """)
  2694. add_newdoc("scipy.special", "_igam_fac",
  2695. """
  2696. Internal function, do not use.
  2697. """)
  2698. add_newdoc("scipy.special", "it2i0k0",
  2699. """
  2700. it2i0k0(x)
  2701. Integrals related to modified Bessel functions of order 0
  2702. Returns
  2703. -------
  2704. ii0
  2705. ``integral((i0(t)-1)/t, t=0..x)``
  2706. ik0
  2707. ``integral(k0(t)/t, t=x..inf)``
  2708. """)
  2709. add_newdoc("scipy.special", "it2j0y0",
  2710. """
  2711. it2j0y0(x)
  2712. Integrals related to Bessel functions of order 0
  2713. Returns
  2714. -------
  2715. ij0
  2716. ``integral((1-j0(t))/t, t=0..x)``
  2717. iy0
  2718. ``integral(y0(t)/t, t=x..inf)``
  2719. """)
  2720. add_newdoc("scipy.special", "it2struve0",
  2721. r"""
  2722. it2struve0(x)
  2723. Integral related to the Struve function of order 0.
  2724. Returns the integral,
  2725. .. math::
  2726. \int_x^\infty \frac{H_0(t)}{t}\,dt
  2727. where :math:`H_0` is the Struve function of order 0.
  2728. Parameters
  2729. ----------
  2730. x : array_like
  2731. Lower limit of integration.
  2732. Returns
  2733. -------
  2734. I : ndarray
  2735. The value of the integral.
  2736. See also
  2737. --------
  2738. struve
  2739. Notes
  2740. -----
  2741. Wrapper for a Fortran routine created by Shanjie Zhang and Jianming
  2742. Jin [1]_.
  2743. References
  2744. ----------
  2745. .. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
  2746. Functions", John Wiley and Sons, 1996.
  2747. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
  2748. """)
  2749. add_newdoc("scipy.special", "itairy",
  2750. """
  2751. itairy(x)
  2752. Integrals of Airy functions
  2753. Calculates the integrals of Airy functions from 0 to `x`.
  2754. Parameters
  2755. ----------
  2756. x: array_like
  2757. Upper limit of integration (float).
  2758. Returns
  2759. -------
  2760. Apt
  2761. Integral of Ai(t) from 0 to x.
  2762. Bpt
  2763. Integral of Bi(t) from 0 to x.
  2764. Ant
  2765. Integral of Ai(-t) from 0 to x.
  2766. Bnt
  2767. Integral of Bi(-t) from 0 to x.
  2768. Notes
  2769. -----
  2770. Wrapper for a Fortran routine created by Shanjie Zhang and Jianming
  2771. Jin [1]_.
  2772. References
  2773. ----------
  2774. .. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
  2775. Functions", John Wiley and Sons, 1996.
  2776. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
  2777. """)
  2778. add_newdoc("scipy.special", "iti0k0",
  2779. """
  2780. iti0k0(x)
  2781. Integrals of modified Bessel functions of order 0
  2782. Returns simple integrals from 0 to `x` of the zeroth order modified
  2783. Bessel functions `i0` and `k0`.
  2784. Returns
  2785. -------
  2786. ii0, ik0
  2787. """)
  2788. add_newdoc("scipy.special", "itj0y0",
  2789. """
  2790. itj0y0(x)
  2791. Integrals of Bessel functions of order 0
  2792. Returns simple integrals from 0 to `x` of the zeroth order Bessel
  2793. functions `j0` and `y0`.
  2794. Returns
  2795. -------
  2796. ij0, iy0
  2797. """)
  2798. add_newdoc("scipy.special", "itmodstruve0",
  2799. r"""
  2800. itmodstruve0(x)
  2801. Integral of the modified Struve function of order 0.
  2802. .. math::
  2803. I = \int_0^x L_0(t)\,dt
  2804. Parameters
  2805. ----------
  2806. x : array_like
  2807. Upper limit of integration (float).
  2808. Returns
  2809. -------
  2810. I : ndarray
  2811. The integral of :math:`L_0` from 0 to `x`.
  2812. Notes
  2813. -----
  2814. Wrapper for a Fortran routine created by Shanjie Zhang and Jianming
  2815. Jin [1]_.
  2816. References
  2817. ----------
  2818. .. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
  2819. Functions", John Wiley and Sons, 1996.
  2820. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
  2821. """)
  2822. add_newdoc("scipy.special", "itstruve0",
  2823. r"""
  2824. itstruve0(x)
  2825. Integral of the Struve function of order 0.
  2826. .. math::
  2827. I = \int_0^x H_0(t)\,dt
  2828. Parameters
  2829. ----------
  2830. x : array_like
  2831. Upper limit of integration (float).
  2832. Returns
  2833. -------
  2834. I : ndarray
  2835. The integral of :math:`H_0` from 0 to `x`.
  2836. See also
  2837. --------
  2838. struve
  2839. Notes
  2840. -----
  2841. Wrapper for a Fortran routine created by Shanjie Zhang and Jianming
  2842. Jin [1]_.
  2843. References
  2844. ----------
  2845. .. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
  2846. Functions", John Wiley and Sons, 1996.
  2847. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
  2848. """)
  2849. add_newdoc("scipy.special", "iv",
  2850. r"""
  2851. iv(v, z)
  2852. Modified Bessel function of the first kind of real order.
  2853. Parameters
  2854. ----------
  2855. v : array_like
  2856. Order. If `z` is of real type and negative, `v` must be integer
  2857. valued.
  2858. z : array_like of float or complex
  2859. Argument.
  2860. Returns
  2861. -------
  2862. out : ndarray
  2863. Values of the modified Bessel function.
  2864. Notes
  2865. -----
  2866. For real `z` and :math:`v \in [-50, 50]`, the evaluation is carried out
  2867. using Temme's method [1]_. For larger orders, uniform asymptotic
  2868. expansions are applied.
  2869. For complex `z` and positive `v`, the AMOS [2]_ `zbesi` routine is
  2870. called. It uses a power series for small `z`, the asymptotic expansion
  2871. for large `abs(z)`, the Miller algorithm normalized by the Wronskian
  2872. and a Neumann series for intermediate magnitudes, and the uniform
  2873. asymptotic expansions for :math:`I_v(z)` and :math:`J_v(z)` for large
  2874. orders. Backward recurrence is used to generate sequences or reduce
  2875. orders when necessary.
  2876. The calculations above are done in the right half plane and continued
  2877. into the left half plane by the formula,
  2878. .. math:: I_v(z \exp(\pm\imath\pi)) = \exp(\pm\pi v) I_v(z)
  2879. (valid when the real part of `z` is positive). For negative `v`, the
  2880. formula
  2881. .. math:: I_{-v}(z) = I_v(z) + \frac{2}{\pi} \sin(\pi v) K_v(z)
  2882. is used, where :math:`K_v(z)` is the modified Bessel function of the
  2883. second kind, evaluated using the AMOS routine `zbesk`.
  2884. See also
  2885. --------
  2886. kve : This function with leading exponential behavior stripped off.
  2887. References
  2888. ----------
  2889. .. [1] Temme, Journal of Computational Physics, vol 21, 343 (1976)
  2890. .. [2] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  2891. of a Complex Argument and Nonnegative Order",
  2892. http://netlib.org/amos/
  2893. """)
  2894. add_newdoc("scipy.special", "ive",
  2895. r"""
  2896. ive(v, z)
  2897. Exponentially scaled modified Bessel function of the first kind
  2898. Defined as::
  2899. ive(v, z) = iv(v, z) * exp(-abs(z.real))
  2900. Parameters
  2901. ----------
  2902. v : array_like of float
  2903. Order.
  2904. z : array_like of float or complex
  2905. Argument.
  2906. Returns
  2907. -------
  2908. out : ndarray
  2909. Values of the exponentially scaled modified Bessel function.
  2910. Notes
  2911. -----
  2912. For positive `v`, the AMOS [1]_ `zbesi` routine is called. It uses a
  2913. power series for small `z`, the asymptotic expansion for large
  2914. `abs(z)`, the Miller algorithm normalized by the Wronskian and a
  2915. Neumann series for intermediate magnitudes, and the uniform asymptotic
  2916. expansions for :math:`I_v(z)` and :math:`J_v(z)` for large orders.
  2917. Backward recurrence is used to generate sequences or reduce orders when
  2918. necessary.
  2919. The calculations above are done in the right half plane and continued
  2920. into the left half plane by the formula,
  2921. .. math:: I_v(z \exp(\pm\imath\pi)) = \exp(\pm\pi v) I_v(z)
  2922. (valid when the real part of `z` is positive). For negative `v`, the
  2923. formula
  2924. .. math:: I_{-v}(z) = I_v(z) + \frac{2}{\pi} \sin(\pi v) K_v(z)
  2925. is used, where :math:`K_v(z)` is the modified Bessel function of the
  2926. second kind, evaluated using the AMOS routine `zbesk`.
  2927. References
  2928. ----------
  2929. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  2930. of a Complex Argument and Nonnegative Order",
  2931. http://netlib.org/amos/
  2932. """)
  2933. add_newdoc("scipy.special", "j0",
  2934. r"""
  2935. j0(x)
  2936. Bessel function of the first kind of order 0.
  2937. Parameters
  2938. ----------
  2939. x : array_like
  2940. Argument (float).
  2941. Returns
  2942. -------
  2943. J : ndarray
  2944. Value of the Bessel function of the first kind of order 0 at `x`.
  2945. Notes
  2946. -----
  2947. The domain is divided into the intervals [0, 5] and (5, infinity). In the
  2948. first interval the following rational approximation is used:
  2949. .. math::
  2950. J_0(x) \approx (w - r_1^2)(w - r_2^2) \frac{P_3(w)}{Q_8(w)},
  2951. where :math:`w = x^2` and :math:`r_1`, :math:`r_2` are the zeros of
  2952. :math:`J_0`, and :math:`P_3` and :math:`Q_8` are polynomials of degrees 3
  2953. and 8, respectively.
  2954. In the second interval, the Hankel asymptotic expansion is employed with
  2955. two rational functions of degree 6/6 and 7/7.
  2956. This function is a wrapper for the Cephes [1]_ routine `j0`.
  2957. It should not be confused with the spherical Bessel functions (see
  2958. `spherical_jn`).
  2959. See also
  2960. --------
  2961. jv : Bessel function of real order and complex argument.
  2962. spherical_jn : spherical Bessel functions.
  2963. References
  2964. ----------
  2965. .. [1] Cephes Mathematical Functions Library,
  2966. http://www.netlib.org/cephes/
  2967. """)
  2968. add_newdoc("scipy.special", "j1",
  2969. """
  2970. j1(x)
  2971. Bessel function of the first kind of order 1.
  2972. Parameters
  2973. ----------
  2974. x : array_like
  2975. Argument (float).
  2976. Returns
  2977. -------
  2978. J : ndarray
  2979. Value of the Bessel function of the first kind of order 1 at `x`.
  2980. Notes
  2981. -----
  2982. The domain is divided into the intervals [0, 8] and (8, infinity). In the
  2983. first interval a 24 term Chebyshev expansion is used. In the second, the
  2984. asymptotic trigonometric representation is employed using two rational
  2985. functions of degree 5/5.
  2986. This function is a wrapper for the Cephes [1]_ routine `j1`.
  2987. It should not be confused with the spherical Bessel functions (see
  2988. `spherical_jn`).
  2989. See also
  2990. --------
  2991. jv
  2992. spherical_jn : spherical Bessel functions.
  2993. References
  2994. ----------
  2995. .. [1] Cephes Mathematical Functions Library,
  2996. http://www.netlib.org/cephes/
  2997. """)
  2998. add_newdoc("scipy.special", "jn",
  2999. """
  3000. jn(n, x)
  3001. Bessel function of the first kind of integer order and real argument.
  3002. Notes
  3003. -----
  3004. `jn` is an alias of `jv`.
  3005. Not to be confused with the spherical Bessel functions (see `spherical_jn`).
  3006. See also
  3007. --------
  3008. jv
  3009. spherical_jn : spherical Bessel functions.
  3010. """)
  3011. add_newdoc("scipy.special", "jv",
  3012. r"""
  3013. jv(v, z)
  3014. Bessel function of the first kind of real order and complex argument.
  3015. Parameters
  3016. ----------
  3017. v : array_like
  3018. Order (float).
  3019. z : array_like
  3020. Argument (float or complex).
  3021. Returns
  3022. -------
  3023. J : ndarray
  3024. Value of the Bessel function, :math:`J_v(z)`.
  3025. Notes
  3026. -----
  3027. For positive `v` values, the computation is carried out using the AMOS
  3028. [1]_ `zbesj` routine, which exploits the connection to the modified
  3029. Bessel function :math:`I_v`,
  3030. .. math::
  3031. J_v(z) = \exp(v\pi\imath/2) I_v(-\imath z)\qquad (\Im z > 0)
  3032. J_v(z) = \exp(-v\pi\imath/2) I_v(\imath z)\qquad (\Im z < 0)
  3033. For negative `v` values the formula,
  3034. .. math:: J_{-v}(z) = J_v(z) \cos(\pi v) - Y_v(z) \sin(\pi v)
  3035. is used, where :math:`Y_v(z)` is the Bessel function of the second
  3036. kind, computed using the AMOS routine `zbesy`. Note that the second
  3037. term is exactly zero for integer `v`; to improve accuracy the second
  3038. term is explicitly omitted for `v` values such that `v = floor(v)`.
  3039. Not to be confused with the spherical Bessel functions (see `spherical_jn`).
  3040. See also
  3041. --------
  3042. jve : :math:`J_v` with leading exponential behavior stripped off.
  3043. spherical_jn : spherical Bessel functions.
  3044. References
  3045. ----------
  3046. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  3047. of a Complex Argument and Nonnegative Order",
  3048. http://netlib.org/amos/
  3049. """)
  3050. add_newdoc("scipy.special", "jve",
  3051. r"""
  3052. jve(v, z)
  3053. Exponentially scaled Bessel function of order `v`.
  3054. Defined as::
  3055. jve(v, z) = jv(v, z) * exp(-abs(z.imag))
  3056. Parameters
  3057. ----------
  3058. v : array_like
  3059. Order (float).
  3060. z : array_like
  3061. Argument (float or complex).
  3062. Returns
  3063. -------
  3064. J : ndarray
  3065. Value of the exponentially scaled Bessel function.
  3066. Notes
  3067. -----
  3068. For positive `v` values, the computation is carried out using the AMOS
  3069. [1]_ `zbesj` routine, which exploits the connection to the modified
  3070. Bessel function :math:`I_v`,
  3071. .. math::
  3072. J_v(z) = \exp(v\pi\imath/2) I_v(-\imath z)\qquad (\Im z > 0)
  3073. J_v(z) = \exp(-v\pi\imath/2) I_v(\imath z)\qquad (\Im z < 0)
  3074. For negative `v` values the formula,
  3075. .. math:: J_{-v}(z) = J_v(z) \cos(\pi v) - Y_v(z) \sin(\pi v)
  3076. is used, where :math:`Y_v(z)` is the Bessel function of the second
  3077. kind, computed using the AMOS routine `zbesy`. Note that the second
  3078. term is exactly zero for integer `v`; to improve accuracy the second
  3079. term is explicitly omitted for `v` values such that `v = floor(v)`.
  3080. References
  3081. ----------
  3082. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  3083. of a Complex Argument and Nonnegative Order",
  3084. http://netlib.org/amos/
  3085. """)
  3086. add_newdoc("scipy.special", "k0",
  3087. r"""
  3088. k0(x)
  3089. Modified Bessel function of the second kind of order 0, :math:`K_0`.
  3090. This function is also sometimes referred to as the modified Bessel
  3091. function of the third kind of order 0.
  3092. Parameters
  3093. ----------
  3094. x : array_like
  3095. Argument (float).
  3096. Returns
  3097. -------
  3098. K : ndarray
  3099. Value of the modified Bessel function :math:`K_0` at `x`.
  3100. Notes
  3101. -----
  3102. The range is partitioned into the two intervals [0, 2] and (2, infinity).
  3103. Chebyshev polynomial expansions are employed in each interval.
  3104. This function is a wrapper for the Cephes [1]_ routine `k0`.
  3105. See also
  3106. --------
  3107. kv
  3108. k0e
  3109. References
  3110. ----------
  3111. .. [1] Cephes Mathematical Functions Library,
  3112. http://www.netlib.org/cephes/
  3113. """)
  3114. add_newdoc("scipy.special", "k0e",
  3115. """
  3116. k0e(x)
  3117. Exponentially scaled modified Bessel function K of order 0
  3118. Defined as::
  3119. k0e(x) = exp(x) * k0(x).
  3120. Parameters
  3121. ----------
  3122. x : array_like
  3123. Argument (float)
  3124. Returns
  3125. -------
  3126. K : ndarray
  3127. Value of the exponentially scaled modified Bessel function K of order
  3128. 0 at `x`.
  3129. Notes
  3130. -----
  3131. The range is partitioned into the two intervals [0, 2] and (2, infinity).
  3132. Chebyshev polynomial expansions are employed in each interval.
  3133. This function is a wrapper for the Cephes [1]_ routine `k0e`.
  3134. See also
  3135. --------
  3136. kv
  3137. k0
  3138. References
  3139. ----------
  3140. .. [1] Cephes Mathematical Functions Library,
  3141. http://www.netlib.org/cephes/
  3142. """)
  3143. add_newdoc("scipy.special", "k1",
  3144. """
  3145. k1(x)
  3146. Modified Bessel function of the second kind of order 1, :math:`K_1(x)`.
  3147. Parameters
  3148. ----------
  3149. x : array_like
  3150. Argument (float)
  3151. Returns
  3152. -------
  3153. K : ndarray
  3154. Value of the modified Bessel function K of order 1 at `x`.
  3155. Notes
  3156. -----
  3157. The range is partitioned into the two intervals [0, 2] and (2, infinity).
  3158. Chebyshev polynomial expansions are employed in each interval.
  3159. This function is a wrapper for the Cephes [1]_ routine `k1`.
  3160. See also
  3161. --------
  3162. kv
  3163. k1e
  3164. References
  3165. ----------
  3166. .. [1] Cephes Mathematical Functions Library,
  3167. http://www.netlib.org/cephes/
  3168. """)
  3169. add_newdoc("scipy.special", "k1e",
  3170. """
  3171. k1e(x)
  3172. Exponentially scaled modified Bessel function K of order 1
  3173. Defined as::
  3174. k1e(x) = exp(x) * k1(x)
  3175. Parameters
  3176. ----------
  3177. x : array_like
  3178. Argument (float)
  3179. Returns
  3180. -------
  3181. K : ndarray
  3182. Value of the exponentially scaled modified Bessel function K of order
  3183. 1 at `x`.
  3184. Notes
  3185. -----
  3186. The range is partitioned into the two intervals [0, 2] and (2, infinity).
  3187. Chebyshev polynomial expansions are employed in each interval.
  3188. This function is a wrapper for the Cephes [1]_ routine `k1e`.
  3189. See also
  3190. --------
  3191. kv
  3192. k1
  3193. References
  3194. ----------
  3195. .. [1] Cephes Mathematical Functions Library,
  3196. http://www.netlib.org/cephes/
  3197. """)
  3198. add_newdoc("scipy.special", "kei",
  3199. """
  3200. kei(x)
  3201. Kelvin function ker
  3202. """)
  3203. add_newdoc("scipy.special", "keip",
  3204. """
  3205. keip(x)
  3206. Derivative of the Kelvin function kei
  3207. """)
  3208. add_newdoc("scipy.special", "kelvin",
  3209. """
  3210. kelvin(x)
  3211. Kelvin functions as complex numbers
  3212. Returns
  3213. -------
  3214. Be, Ke, Bep, Kep
  3215. The tuple (Be, Ke, Bep, Kep) contains complex numbers
  3216. representing the real and imaginary Kelvin functions and their
  3217. derivatives evaluated at `x`. For example, kelvin(x)[0].real =
  3218. ber x and kelvin(x)[0].imag = bei x with similar relationships
  3219. for ker and kei.
  3220. """)
  3221. add_newdoc("scipy.special", "ker",
  3222. """
  3223. ker(x)
  3224. Kelvin function ker
  3225. """)
  3226. add_newdoc("scipy.special", "kerp",
  3227. """
  3228. kerp(x)
  3229. Derivative of the Kelvin function ker
  3230. """)
  3231. add_newdoc("scipy.special", "kl_div",
  3232. r"""
  3233. kl_div(x, y)
  3234. Elementwise function for computing Kullback-Leibler divergence.
  3235. .. math:: \mathrm{kl\_div}(x, y) = \begin{cases} x \log(x / y) - x + y & x > 0, y > 0 \\ y & x = 0, y \ge 0 \\ \infty & \text{otherwise} \end{cases}
  3236. Parameters
  3237. ----------
  3238. x : ndarray
  3239. First input array.
  3240. y : ndarray
  3241. Second input array.
  3242. Returns
  3243. -------
  3244. res : ndarray
  3245. Output array.
  3246. See Also
  3247. --------
  3248. entr, rel_entr
  3249. Notes
  3250. -----
  3251. This function is non-negative and is jointly convex in `x` and `y`.
  3252. .. versionadded:: 0.15.0
  3253. """)
  3254. add_newdoc("scipy.special", "kn",
  3255. r"""
  3256. kn(n, x)
  3257. Modified Bessel function of the second kind of integer order `n`
  3258. Returns the modified Bessel function of the second kind for integer order
  3259. `n` at real `z`.
  3260. These are also sometimes called functions of the third kind, Basset
  3261. functions, or Macdonald functions.
  3262. Parameters
  3263. ----------
  3264. n : array_like of int
  3265. Order of Bessel functions (floats will truncate with a warning)
  3266. z : array_like of float
  3267. Argument at which to evaluate the Bessel functions
  3268. Returns
  3269. -------
  3270. out : ndarray
  3271. The results
  3272. Notes
  3273. -----
  3274. Wrapper for AMOS [1]_ routine `zbesk`. For a discussion of the
  3275. algorithm used, see [2]_ and the references therein.
  3276. See Also
  3277. --------
  3278. kv : Same function, but accepts real order and complex argument
  3279. kvp : Derivative of this function
  3280. References
  3281. ----------
  3282. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  3283. of a Complex Argument and Nonnegative Order",
  3284. http://netlib.org/amos/
  3285. .. [2] Donald E. Amos, "Algorithm 644: A portable package for Bessel
  3286. functions of a complex argument and nonnegative order", ACM
  3287. TOMS Vol. 12 Issue 3, Sept. 1986, p. 265
  3288. Examples
  3289. --------
  3290. Plot the function of several orders for real input:
  3291. >>> from scipy.special import kn
  3292. >>> import matplotlib.pyplot as plt
  3293. >>> x = np.linspace(0, 5, 1000)
  3294. >>> for N in range(6):
  3295. ... plt.plot(x, kn(N, x), label='$K_{}(x)$'.format(N))
  3296. >>> plt.ylim(0, 10)
  3297. >>> plt.legend()
  3298. >>> plt.title(r'Modified Bessel function of the second kind $K_n(x)$')
  3299. >>> plt.show()
  3300. Calculate for a single value at multiple orders:
  3301. >>> kn([4, 5, 6], 1)
  3302. array([ 44.23241585, 360.9605896 , 3653.83831186])
  3303. """)
  3304. add_newdoc("scipy.special", "kolmogi",
  3305. """
  3306. kolmogi(p)
  3307. Inverse Survival Function of Kolmogorov distribution
  3308. It is the inverse function to `kolmogorov`.
  3309. Returns y such that ``kolmogorov(y) == p``.
  3310. Parameters
  3311. ----------
  3312. p : float array_like
  3313. Probability
  3314. Returns
  3315. -------
  3316. float
  3317. The value(s) of kolmogi(p)
  3318. Notes
  3319. -----
  3320. `kolmogorov` is used by `stats.kstest` in the application of the
  3321. Kolmogorov-Smirnov Goodness of Fit test. For historial reasons this
  3322. function is exposed in `scpy.special`, but the recommended way to achieve
  3323. the most accurate CDF/SF/PDF/PPF/ISF computations is to use the
  3324. `stats.kstwobign` distrubution.
  3325. See Also
  3326. --------
  3327. kolmogorov : The Survival Function for the distribution
  3328. scipy.stats.kstwobign : Provides the functionality as a continuous distribution
  3329. smirnov, smirnovi : Functions for the one-sided distribution
  3330. Examples
  3331. --------
  3332. >>> from scipy.special import kolmogi
  3333. >>> kolmogi([0, 0.1, 0.25, 0.5, 0.75, 0.9, 1.0])
  3334. array([ inf, 1.22384787, 1.01918472, 0.82757356, 0.67644769,
  3335. 0.57117327, 0. ])
  3336. """)
  3337. add_newdoc("scipy.special", "kolmogorov",
  3338. r"""
  3339. kolmogorov(y)
  3340. Complementary cumulative distribution (Survival Function) function of
  3341. Kolmogorov distribution.
  3342. Returns the complementary cumulative distribution function of
  3343. Kolmogorov's limiting distribution (``D_n*\sqrt(n)`` as n goes to infinity)
  3344. of a two-sided test for equality between an empirical and a theoretical
  3345. distribution. It is equal to the (limit as n->infinity of the)
  3346. probability that ``sqrt(n) * max absolute deviation > y``.
  3347. Parameters
  3348. ----------
  3349. y : float array_like
  3350. Absolute deviation between the Empirical CDF (ECDF) and the target CDF,
  3351. multiplied by sqrt(n).
  3352. Returns
  3353. -------
  3354. float
  3355. The value(s) of kolmogorov(y)
  3356. Notes
  3357. -----
  3358. `kolmogorov` is used by `stats.kstest` in the application of the
  3359. Kolmogorov-Smirnov Goodness of Fit test. For historial reasons this
  3360. function is exposed in `scpy.special`, but the recommended way to achieve
  3361. the most accurate CDF/SF/PDF/PPF/ISF computations is to use the
  3362. `stats.kstwobign` distrubution.
  3363. See Also
  3364. --------
  3365. kolmogi : The Inverse Survival Function for the distribution
  3366. scipy.stats.kstwobign : Provides the functionality as a continuous distribution
  3367. smirnov, smirnovi : Functions for the one-sided distribution
  3368. Examples
  3369. --------
  3370. Show the probability of a gap at least as big as 0, 0.5 and 1.0.
  3371. >>> from scipy.special import kolmogorov
  3372. >>> from scipy.stats import kstwobign
  3373. >>> kolmogorov([0, 0.5, 1.0])
  3374. array([ 1. , 0.96394524, 0.26999967])
  3375. Compare a sample of size 1000 drawn from a Laplace(0, 1) distribution against
  3376. the target distribution, a Normal(0, 1) distribution.
  3377. >>> from scipy.stats import norm, laplace
  3378. >>> n = 1000
  3379. >>> np.random.seed(seed=233423)
  3380. >>> lap01 = laplace(0, 1)
  3381. >>> x = np.sort(lap01.rvs(n))
  3382. >>> np.mean(x), np.std(x)
  3383. (-0.083073685397609842, 1.3676426568399822)
  3384. Construct the Empirical CDF and the K-S statistic Dn.
  3385. >>> target = norm(0,1) # Normal mean 0, stddev 1
  3386. >>> cdfs = target.cdf(x)
  3387. >>> ecdfs = np.arange(n+1, dtype=float)/n
  3388. >>> gaps = np.column_stack([cdfs - ecdfs[:n], ecdfs[1:] - cdfs])
  3389. >>> Dn = np.max(gaps)
  3390. >>> Kn = np.sqrt(n) * Dn
  3391. >>> print('Dn=%f, sqrt(n)*Dn=%f' % (Dn, Kn))
  3392. Dn=0.058286, sqrt(n)*Dn=1.843153
  3393. >>> print(chr(10).join(['For a sample of size n drawn from a N(0, 1) distribution:',
  3394. ... ' the approximate Kolmogorov probability that sqrt(n)*Dn>=%f is %f' % (Kn, kolmogorov(Kn)),
  3395. ... ' the approximate Kolmogorov probability that sqrt(n)*Dn<=%f is %f' % (Kn, kstwobign.cdf(Kn))]))
  3396. For a sample of size n drawn from a N(0, 1) distribution:
  3397. the approximate Kolmogorov probability that sqrt(n)*Dn>=1.843153 is 0.002240
  3398. the approximate Kolmogorov probability that sqrt(n)*Dn<=1.843153 is 0.997760
  3399. Plot the Empirical CDF against the target N(0, 1) CDF.
  3400. >>> import matplotlib.pyplot as plt
  3401. >>> plt.step(np.concatenate([[-3], x]), ecdfs, where='post', label='Empirical CDF')
  3402. >>> x3 = np.linspace(-3, 3, 100)
  3403. >>> plt.plot(x3, target.cdf(x3), label='CDF for N(0, 1)')
  3404. >>> plt.ylim([0, 1]); plt.grid(True); plt.legend();
  3405. >>> # Add vertical lines marking Dn+ and Dn-
  3406. >>> iminus, iplus = np.argmax(gaps, axis=0)
  3407. >>> plt.vlines([x[iminus]], ecdfs[iminus], cdfs[iminus], color='r', linestyle='dashed', lw=4)
  3408. >>> plt.vlines([x[iplus]], cdfs[iplus], ecdfs[iplus+1], color='r', linestyle='dashed', lw=4)
  3409. >>> plt.show()
  3410. """)
  3411. add_newdoc("scipy.special", "_kolmogc",
  3412. r"""
  3413. Internal function, do not use.
  3414. """)
  3415. add_newdoc("scipy.special", "_kolmogci",
  3416. r"""
  3417. Internal function, do not use.
  3418. """)
  3419. add_newdoc("scipy.special", "_kolmogp",
  3420. r"""
  3421. Internal function, do not use.
  3422. """)
  3423. add_newdoc("scipy.special", "kv",
  3424. r"""
  3425. kv(v, z)
  3426. Modified Bessel function of the second kind of real order `v`
  3427. Returns the modified Bessel function of the second kind for real order
  3428. `v` at complex `z`.
  3429. These are also sometimes called functions of the third kind, Basset
  3430. functions, or Macdonald functions. They are defined as those solutions
  3431. of the modified Bessel equation for which,
  3432. .. math::
  3433. K_v(x) \sim \sqrt{\pi/(2x)} \exp(-x)
  3434. as :math:`x \to \infty` [3]_.
  3435. Parameters
  3436. ----------
  3437. v : array_like of float
  3438. Order of Bessel functions
  3439. z : array_like of complex
  3440. Argument at which to evaluate the Bessel functions
  3441. Returns
  3442. -------
  3443. out : ndarray
  3444. The results. Note that input must be of complex type to get complex
  3445. output, e.g. ``kv(3, -2+0j)`` instead of ``kv(3, -2)``.
  3446. Notes
  3447. -----
  3448. Wrapper for AMOS [1]_ routine `zbesk`. For a discussion of the
  3449. algorithm used, see [2]_ and the references therein.
  3450. See Also
  3451. --------
  3452. kve : This function with leading exponential behavior stripped off.
  3453. kvp : Derivative of this function
  3454. References
  3455. ----------
  3456. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  3457. of a Complex Argument and Nonnegative Order",
  3458. http://netlib.org/amos/
  3459. .. [2] Donald E. Amos, "Algorithm 644: A portable package for Bessel
  3460. functions of a complex argument and nonnegative order", ACM
  3461. TOMS Vol. 12 Issue 3, Sept. 1986, p. 265
  3462. .. [3] NIST Digital Library of Mathematical Functions,
  3463. Eq. 10.25.E3. https://dlmf.nist.gov/10.25.E3
  3464. Examples
  3465. --------
  3466. Plot the function of several orders for real input:
  3467. >>> from scipy.special import kv
  3468. >>> import matplotlib.pyplot as plt
  3469. >>> x = np.linspace(0, 5, 1000)
  3470. >>> for N in np.linspace(0, 6, 5):
  3471. ... plt.plot(x, kv(N, x), label='$K_{{{}}}(x)$'.format(N))
  3472. >>> plt.ylim(0, 10)
  3473. >>> plt.legend()
  3474. >>> plt.title(r'Modified Bessel function of the second kind $K_\nu(x)$')
  3475. >>> plt.show()
  3476. Calculate for a single value at multiple orders:
  3477. >>> kv([4, 4.5, 5], 1+2j)
  3478. array([ 0.1992+2.3892j, 2.3493+3.6j , 7.2827+3.8104j])
  3479. """)
  3480. add_newdoc("scipy.special", "kve",
  3481. r"""
  3482. kve(v, z)
  3483. Exponentially scaled modified Bessel function of the second kind.
  3484. Returns the exponentially scaled, modified Bessel function of the
  3485. second kind (sometimes called the third kind) for real order `v` at
  3486. complex `z`::
  3487. kve(v, z) = kv(v, z) * exp(z)
  3488. Parameters
  3489. ----------
  3490. v : array_like of float
  3491. Order of Bessel functions
  3492. z : array_like of complex
  3493. Argument at which to evaluate the Bessel functions
  3494. Returns
  3495. -------
  3496. out : ndarray
  3497. The exponentially scaled modified Bessel function of the second kind.
  3498. Notes
  3499. -----
  3500. Wrapper for AMOS [1]_ routine `zbesk`. For a discussion of the
  3501. algorithm used, see [2]_ and the references therein.
  3502. References
  3503. ----------
  3504. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  3505. of a Complex Argument and Nonnegative Order",
  3506. http://netlib.org/amos/
  3507. .. [2] Donald E. Amos, "Algorithm 644: A portable package for Bessel
  3508. functions of a complex argument and nonnegative order", ACM
  3509. TOMS Vol. 12 Issue 3, Sept. 1986, p. 265
  3510. """)
  3511. add_newdoc("scipy.special", "_lanczos_sum_expg_scaled",
  3512. """
  3513. Internal function, do not use.
  3514. """)
  3515. add_newdoc("scipy.special", "_lgam1p",
  3516. """
  3517. Internal function, do not use.
  3518. """)
  3519. add_newdoc("scipy.special", "log1p",
  3520. """
  3521. log1p(x)
  3522. Calculates log(1+x) for use when `x` is near zero
  3523. """)
  3524. add_newdoc("scipy.special", "_log1pmx",
  3525. """
  3526. Internal function, do not use.
  3527. """)
  3528. add_newdoc('scipy.special', 'logit',
  3529. """
  3530. logit(x)
  3531. Logit ufunc for ndarrays.
  3532. The logit function is defined as logit(p) = log(p/(1-p)).
  3533. Note that logit(0) = -inf, logit(1) = inf, and logit(p)
  3534. for p<0 or p>1 yields nan.
  3535. Parameters
  3536. ----------
  3537. x : ndarray
  3538. The ndarray to apply logit to element-wise.
  3539. Returns
  3540. -------
  3541. out : ndarray
  3542. An ndarray of the same shape as x. Its entries
  3543. are logit of the corresponding entry of x.
  3544. See Also
  3545. --------
  3546. expit
  3547. Notes
  3548. -----
  3549. As a ufunc logit takes a number of optional
  3550. keyword arguments. For more information
  3551. see `ufuncs <https://docs.scipy.org/doc/numpy/reference/ufuncs.html>`_
  3552. .. versionadded:: 0.10.0
  3553. Examples
  3554. --------
  3555. >>> from scipy.special import logit, expit
  3556. >>> logit([0, 0.25, 0.5, 0.75, 1])
  3557. array([ -inf, -1.09861229, 0. , 1.09861229, inf])
  3558. `expit` is the inverse of `logit`:
  3559. >>> expit(logit([0.1, 0.75, 0.999]))
  3560. array([ 0.1 , 0.75 , 0.999])
  3561. Plot logit(x) for x in [0, 1]:
  3562. >>> import matplotlib.pyplot as plt
  3563. >>> x = np.linspace(0, 1, 501)
  3564. >>> y = logit(x)
  3565. >>> plt.plot(x, y)
  3566. >>> plt.grid()
  3567. >>> plt.ylim(-6, 6)
  3568. >>> plt.xlabel('x')
  3569. >>> plt.title('logit(x)')
  3570. >>> plt.show()
  3571. """)
  3572. add_newdoc("scipy.special", "lpmv",
  3573. r"""
  3574. lpmv(m, v, x)
  3575. Associated Legendre function of integer order and real degree.
  3576. Defined as
  3577. .. math::
  3578. P_v^m = (-1)^m (1 - x^2)^{m/2} \frac{d^m}{dx^m} P_v(x)
  3579. where
  3580. .. math::
  3581. P_v = \sum_{k = 0}^\infty \frac{(-v)_k (v + 1)_k}{(k!)^2}
  3582. \left(\frac{1 - x}{2}\right)^k
  3583. is the Legendre function of the first kind. Here :math:`(\cdot)_k`
  3584. is the Pochhammer symbol; see `poch`.
  3585. Parameters
  3586. ----------
  3587. m : array_like
  3588. Order (int or float). If passed a float not equal to an
  3589. integer the function returns NaN.
  3590. v : array_like
  3591. Degree (float).
  3592. x : array_like
  3593. Argument (float). Must have ``|x| <= 1``.
  3594. Returns
  3595. -------
  3596. pmv : ndarray
  3597. Value of the associated Legendre function.
  3598. See Also
  3599. --------
  3600. lpmn : Compute the associated Legendre function for all orders
  3601. ``0, ..., m`` and degrees ``0, ..., n``.
  3602. clpmn : Compute the associated Legendre function at complex
  3603. arguments.
  3604. Notes
  3605. -----
  3606. Note that this implementation includes the Condon-Shortley phase.
  3607. References
  3608. ----------
  3609. .. [1] Zhang, Jin, "Computation of Special Functions", John Wiley
  3610. and Sons, Inc, 1996.
  3611. """)
  3612. add_newdoc("scipy.special", "mathieu_a",
  3613. """
  3614. mathieu_a(m, q)
  3615. Characteristic value of even Mathieu functions
  3616. Returns the characteristic value for the even solution,
  3617. ``ce_m(z, q)``, of Mathieu's equation.
  3618. """)
  3619. add_newdoc("scipy.special", "mathieu_b",
  3620. """
  3621. mathieu_b(m, q)
  3622. Characteristic value of odd Mathieu functions
  3623. Returns the characteristic value for the odd solution,
  3624. ``se_m(z, q)``, of Mathieu's equation.
  3625. """)
  3626. add_newdoc("scipy.special", "mathieu_cem",
  3627. """
  3628. mathieu_cem(m, q, x)
  3629. Even Mathieu function and its derivative
  3630. Returns the even Mathieu function, ``ce_m(x, q)``, of order `m` and
  3631. parameter `q` evaluated at `x` (given in degrees). Also returns the
  3632. derivative with respect to `x` of ce_m(x, q)
  3633. Parameters
  3634. ----------
  3635. m
  3636. Order of the function
  3637. q
  3638. Parameter of the function
  3639. x
  3640. Argument of the function, *given in degrees, not radians*
  3641. Returns
  3642. -------
  3643. y
  3644. Value of the function
  3645. yp
  3646. Value of the derivative vs x
  3647. """)
  3648. add_newdoc("scipy.special", "mathieu_modcem1",
  3649. """
  3650. mathieu_modcem1(m, q, x)
  3651. Even modified Mathieu function of the first kind and its derivative
  3652. Evaluates the even modified Mathieu function of the first kind,
  3653. ``Mc1m(x, q)``, and its derivative at `x` for order `m` and parameter
  3654. `q`.
  3655. Returns
  3656. -------
  3657. y
  3658. Value of the function
  3659. yp
  3660. Value of the derivative vs x
  3661. """)
  3662. add_newdoc("scipy.special", "mathieu_modcem2",
  3663. """
  3664. mathieu_modcem2(m, q, x)
  3665. Even modified Mathieu function of the second kind and its derivative
  3666. Evaluates the even modified Mathieu function of the second kind,
  3667. Mc2m(x, q), and its derivative at `x` (given in degrees) for order `m`
  3668. and parameter `q`.
  3669. Returns
  3670. -------
  3671. y
  3672. Value of the function
  3673. yp
  3674. Value of the derivative vs x
  3675. """)
  3676. add_newdoc("scipy.special", "mathieu_modsem1",
  3677. """
  3678. mathieu_modsem1(m, q, x)
  3679. Odd modified Mathieu function of the first kind and its derivative
  3680. Evaluates the odd modified Mathieu function of the first kind,
  3681. Ms1m(x, q), and its derivative at `x` (given in degrees) for order `m`
  3682. and parameter `q`.
  3683. Returns
  3684. -------
  3685. y
  3686. Value of the function
  3687. yp
  3688. Value of the derivative vs x
  3689. """)
  3690. add_newdoc("scipy.special", "mathieu_modsem2",
  3691. """
  3692. mathieu_modsem2(m, q, x)
  3693. Odd modified Mathieu function of the second kind and its derivative
  3694. Evaluates the odd modified Mathieu function of the second kind,
  3695. Ms2m(x, q), and its derivative at `x` (given in degrees) for order `m`
  3696. and parameter q.
  3697. Returns
  3698. -------
  3699. y
  3700. Value of the function
  3701. yp
  3702. Value of the derivative vs x
  3703. """)
  3704. add_newdoc("scipy.special", "mathieu_sem",
  3705. """
  3706. mathieu_sem(m, q, x)
  3707. Odd Mathieu function and its derivative
  3708. Returns the odd Mathieu function, se_m(x, q), of order `m` and
  3709. parameter `q` evaluated at `x` (given in degrees). Also returns the
  3710. derivative with respect to `x` of se_m(x, q).
  3711. Parameters
  3712. ----------
  3713. m
  3714. Order of the function
  3715. q
  3716. Parameter of the function
  3717. x
  3718. Argument of the function, *given in degrees, not radians*.
  3719. Returns
  3720. -------
  3721. y
  3722. Value of the function
  3723. yp
  3724. Value of the derivative vs x
  3725. """)
  3726. add_newdoc("scipy.special", "modfresnelm",
  3727. """
  3728. modfresnelm(x)
  3729. Modified Fresnel negative integrals
  3730. Returns
  3731. -------
  3732. fm
  3733. Integral ``F_-(x)``: ``integral(exp(-1j*t*t), t=x..inf)``
  3734. km
  3735. Integral ``K_-(x)``: ``1/sqrt(pi)*exp(1j*(x*x+pi/4))*fp``
  3736. """)
  3737. add_newdoc("scipy.special", "modfresnelp",
  3738. """
  3739. modfresnelp(x)
  3740. Modified Fresnel positive integrals
  3741. Returns
  3742. -------
  3743. fp
  3744. Integral ``F_+(x)``: ``integral(exp(1j*t*t), t=x..inf)``
  3745. kp
  3746. Integral ``K_+(x)``: ``1/sqrt(pi)*exp(-1j*(x*x+pi/4))*fp``
  3747. """)
  3748. add_newdoc("scipy.special", "modstruve",
  3749. r"""
  3750. modstruve(v, x)
  3751. Modified Struve function.
  3752. Return the value of the modified Struve function of order `v` at `x`. The
  3753. modified Struve function is defined as,
  3754. .. math::
  3755. L_v(x) = -\imath \exp(-\pi\imath v/2) H_v(x),
  3756. where :math:`H_v` is the Struve function.
  3757. Parameters
  3758. ----------
  3759. v : array_like
  3760. Order of the modified Struve function (float).
  3761. x : array_like
  3762. Argument of the Struve function (float; must be positive unless `v` is
  3763. an integer).
  3764. Returns
  3765. -------
  3766. L : ndarray
  3767. Value of the modified Struve function of order `v` at `x`.
  3768. Notes
  3769. -----
  3770. Three methods discussed in [1]_ are used to evaluate the function:
  3771. - power series
  3772. - expansion in Bessel functions (if :math:`|z| < |v| + 20`)
  3773. - asymptotic large-z expansion (if :math:`z \geq 0.7v + 12`)
  3774. Rounding errors are estimated based on the largest terms in the sums, and
  3775. the result associated with the smallest error is returned.
  3776. See also
  3777. --------
  3778. struve
  3779. References
  3780. ----------
  3781. .. [1] NIST Digital Library of Mathematical Functions
  3782. https://dlmf.nist.gov/11
  3783. """)
  3784. add_newdoc("scipy.special", "nbdtr",
  3785. r"""
  3786. nbdtr(k, n, p)
  3787. Negative binomial cumulative distribution function.
  3788. Returns the sum of the terms 0 through `k` of the negative binomial
  3789. distribution probability mass function,
  3790. .. math::
  3791. F = \sum_{j=0}^k {{n + j - 1}\choose{j}} p^n (1 - p)^j.
  3792. In a sequence of Bernoulli trials with individual success probabilities
  3793. `p`, this is the probability that `k` or fewer failures precede the nth
  3794. success.
  3795. Parameters
  3796. ----------
  3797. k : array_like
  3798. The maximum number of allowed failures (nonnegative int).
  3799. n : array_like
  3800. The target number of successes (positive int).
  3801. p : array_like
  3802. Probability of success in a single event (float).
  3803. Returns
  3804. -------
  3805. F : ndarray
  3806. The probability of `k` or fewer failures before `n` successes in a
  3807. sequence of events with individual success probability `p`.
  3808. See also
  3809. --------
  3810. nbdtrc
  3811. Notes
  3812. -----
  3813. If floating point values are passed for `k` or `n`, they will be truncated
  3814. to integers.
  3815. The terms are not summed directly; instead the regularized incomplete beta
  3816. function is employed, according to the formula,
  3817. .. math::
  3818. \mathrm{nbdtr}(k, n, p) = I_{p}(n, k + 1).
  3819. Wrapper for the Cephes [1]_ routine `nbdtr`.
  3820. References
  3821. ----------
  3822. .. [1] Cephes Mathematical Functions Library,
  3823. http://www.netlib.org/cephes/
  3824. """)
  3825. add_newdoc("scipy.special", "nbdtrc",
  3826. r"""
  3827. nbdtrc(k, n, p)
  3828. Negative binomial survival function.
  3829. Returns the sum of the terms `k + 1` to infinity of the negative binomial
  3830. distribution probability mass function,
  3831. .. math::
  3832. F = \sum_{j=k + 1}^\infty {{n + j - 1}\choose{j}} p^n (1 - p)^j.
  3833. In a sequence of Bernoulli trials with individual success probabilities
  3834. `p`, this is the probability that more than `k` failures precede the nth
  3835. success.
  3836. Parameters
  3837. ----------
  3838. k : array_like
  3839. The maximum number of allowed failures (nonnegative int).
  3840. n : array_like
  3841. The target number of successes (positive int).
  3842. p : array_like
  3843. Probability of success in a single event (float).
  3844. Returns
  3845. -------
  3846. F : ndarray
  3847. The probability of `k + 1` or more failures before `n` successes in a
  3848. sequence of events with individual success probability `p`.
  3849. Notes
  3850. -----
  3851. If floating point values are passed for `k` or `n`, they will be truncated
  3852. to integers.
  3853. The terms are not summed directly; instead the regularized incomplete beta
  3854. function is employed, according to the formula,
  3855. .. math::
  3856. \mathrm{nbdtrc}(k, n, p) = I_{1 - p}(k + 1, n).
  3857. Wrapper for the Cephes [1]_ routine `nbdtrc`.
  3858. References
  3859. ----------
  3860. .. [1] Cephes Mathematical Functions Library,
  3861. http://www.netlib.org/cephes/
  3862. """)
  3863. add_newdoc("scipy.special", "nbdtri",
  3864. """
  3865. nbdtri(k, n, y)
  3866. Inverse of `nbdtr` vs `p`.
  3867. Returns the inverse with respect to the parameter `p` of
  3868. `y = nbdtr(k, n, p)`, the negative binomial cumulative distribution
  3869. function.
  3870. Parameters
  3871. ----------
  3872. k : array_like
  3873. The maximum number of allowed failures (nonnegative int).
  3874. n : array_like
  3875. The target number of successes (positive int).
  3876. y : array_like
  3877. The probability of `k` or fewer failures before `n` successes (float).
  3878. Returns
  3879. -------
  3880. p : ndarray
  3881. Probability of success in a single event (float) such that
  3882. `nbdtr(k, n, p) = y`.
  3883. See also
  3884. --------
  3885. nbdtr : Cumulative distribution function of the negative binomial.
  3886. nbdtrik : Inverse with respect to `k` of `nbdtr(k, n, p)`.
  3887. nbdtrin : Inverse with respect to `n` of `nbdtr(k, n, p)`.
  3888. Notes
  3889. -----
  3890. Wrapper for the Cephes [1]_ routine `nbdtri`.
  3891. References
  3892. ----------
  3893. .. [1] Cephes Mathematical Functions Library,
  3894. http://www.netlib.org/cephes/
  3895. """)
  3896. add_newdoc("scipy.special", "nbdtrik",
  3897. r"""
  3898. nbdtrik(y, n, p)
  3899. Inverse of `nbdtr` vs `k`.
  3900. Returns the inverse with respect to the parameter `k` of
  3901. `y = nbdtr(k, n, p)`, the negative binomial cumulative distribution
  3902. function.
  3903. Parameters
  3904. ----------
  3905. y : array_like
  3906. The probability of `k` or fewer failures before `n` successes (float).
  3907. n : array_like
  3908. The target number of successes (positive int).
  3909. p : array_like
  3910. Probability of success in a single event (float).
  3911. Returns
  3912. -------
  3913. k : ndarray
  3914. The maximum number of allowed failures such that `nbdtr(k, n, p) = y`.
  3915. See also
  3916. --------
  3917. nbdtr : Cumulative distribution function of the negative binomial.
  3918. nbdtri : Inverse with respect to `p` of `nbdtr(k, n, p)`.
  3919. nbdtrin : Inverse with respect to `n` of `nbdtr(k, n, p)`.
  3920. Notes
  3921. -----
  3922. Wrapper for the CDFLIB [1]_ Fortran routine `cdfnbn`.
  3923. Formula 26.5.26 of [2]_,
  3924. .. math::
  3925. \sum_{j=k + 1}^\infty {{n + j - 1}\choose{j}} p^n (1 - p)^j = I_{1 - p}(k + 1, n),
  3926. is used to reduce calculation of the cumulative distribution function to
  3927. that of a regularized incomplete beta :math:`I`.
  3928. Computation of `k` involves a search for a value that produces the desired
  3929. value of `y`. The search relies on the monotonicity of `y` with `k`.
  3930. References
  3931. ----------
  3932. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  3933. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  3934. Functions, Inverses, and Other Parameters.
  3935. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  3936. Handbook of Mathematical Functions with Formulas,
  3937. Graphs, and Mathematical Tables. New York: Dover, 1972.
  3938. """)
  3939. add_newdoc("scipy.special", "nbdtrin",
  3940. r"""
  3941. nbdtrin(k, y, p)
  3942. Inverse of `nbdtr` vs `n`.
  3943. Returns the inverse with respect to the parameter `n` of
  3944. `y = nbdtr(k, n, p)`, the negative binomial cumulative distribution
  3945. function.
  3946. Parameters
  3947. ----------
  3948. k : array_like
  3949. The maximum number of allowed failures (nonnegative int).
  3950. y : array_like
  3951. The probability of `k` or fewer failures before `n` successes (float).
  3952. p : array_like
  3953. Probability of success in a single event (float).
  3954. Returns
  3955. -------
  3956. n : ndarray
  3957. The number of successes `n` such that `nbdtr(k, n, p) = y`.
  3958. See also
  3959. --------
  3960. nbdtr : Cumulative distribution function of the negative binomial.
  3961. nbdtri : Inverse with respect to `p` of `nbdtr(k, n, p)`.
  3962. nbdtrik : Inverse with respect to `k` of `nbdtr(k, n, p)`.
  3963. Notes
  3964. -----
  3965. Wrapper for the CDFLIB [1]_ Fortran routine `cdfnbn`.
  3966. Formula 26.5.26 of [2]_,
  3967. .. math::
  3968. \sum_{j=k + 1}^\infty {{n + j - 1}\choose{j}} p^n (1 - p)^j = I_{1 - p}(k + 1, n),
  3969. is used to reduce calculation of the cumulative distribution function to
  3970. that of a regularized incomplete beta :math:`I`.
  3971. Computation of `n` involves a search for a value that produces the desired
  3972. value of `y`. The search relies on the monotonicity of `y` with `n`.
  3973. References
  3974. ----------
  3975. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  3976. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  3977. Functions, Inverses, and Other Parameters.
  3978. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  3979. Handbook of Mathematical Functions with Formulas,
  3980. Graphs, and Mathematical Tables. New York: Dover, 1972.
  3981. """)
  3982. add_newdoc("scipy.special", "ncfdtr",
  3983. r"""
  3984. ncfdtr(dfn, dfd, nc, f)
  3985. Cumulative distribution function of the non-central F distribution.
  3986. The non-central F describes the distribution of,
  3987. .. math::
  3988. Z = \frac{X/d_n}{Y/d_d}
  3989. where :math:`X` and :math:`Y` are independently distributed, with
  3990. :math:`X` distributed non-central :math:`\chi^2` with noncentrality
  3991. parameter `nc` and :math:`d_n` degrees of freedom, and :math:`Y`
  3992. distributed :math:`\chi^2` with :math:`d_d` degrees of freedom.
  3993. Parameters
  3994. ----------
  3995. dfn : array_like
  3996. Degrees of freedom of the numerator sum of squares. Range (0, inf).
  3997. dfd : array_like
  3998. Degrees of freedom of the denominator sum of squares. Range (0, inf).
  3999. nc : array_like
  4000. Noncentrality parameter. Should be in range (0, 1e4).
  4001. f : array_like
  4002. Quantiles, i.e. the upper limit of integration.
  4003. Returns
  4004. -------
  4005. cdf : float or ndarray
  4006. The calculated CDF. If all inputs are scalar, the return will be a
  4007. float. Otherwise it will be an array.
  4008. See Also
  4009. --------
  4010. ncfdtri : Quantile function; inverse of `ncfdtr` with respect to `f`.
  4011. ncfdtridfd : Inverse of `ncfdtr` with respect to `dfd`.
  4012. ncfdtridfn : Inverse of `ncfdtr` with respect to `dfn`.
  4013. ncfdtrinc : Inverse of `ncfdtr` with respect to `nc`.
  4014. Notes
  4015. -----
  4016. Wrapper for the CDFLIB [1]_ Fortran routine `cdffnc`.
  4017. The cumulative distribution function is computed using Formula 26.6.20 of
  4018. [2]_:
  4019. .. math::
  4020. F(d_n, d_d, n_c, f) = \sum_{j=0}^\infty e^{-n_c/2} \frac{(n_c/2)^j}{j!} I_{x}(\frac{d_n}{2} + j, \frac{d_d}{2}),
  4021. where :math:`I` is the regularized incomplete beta function, and
  4022. :math:`x = f d_n/(f d_n + d_d)`.
  4023. The computation time required for this routine is proportional to the
  4024. noncentrality parameter `nc`. Very large values of this parameter can
  4025. consume immense computer resources. This is why the search range is
  4026. bounded by 10,000.
  4027. References
  4028. ----------
  4029. .. [1] Barry Brown, James Lovato, and Kathy Russell,
  4030. CDFLIB: Library of Fortran Routines for Cumulative Distribution
  4031. Functions, Inverses, and Other Parameters.
  4032. .. [2] Milton Abramowitz and Irene A. Stegun, eds.
  4033. Handbook of Mathematical Functions with Formulas,
  4034. Graphs, and Mathematical Tables. New York: Dover, 1972.
  4035. Examples
  4036. --------
  4037. >>> from scipy import special
  4038. >>> from scipy import stats
  4039. >>> import matplotlib.pyplot as plt
  4040. Plot the CDF of the non-central F distribution, for nc=0. Compare with the
  4041. F-distribution from scipy.stats:
  4042. >>> x = np.linspace(-1, 8, num=500)
  4043. >>> dfn = 3
  4044. >>> dfd = 2
  4045. >>> ncf_stats = stats.f.cdf(x, dfn, dfd)
  4046. >>> ncf_special = special.ncfdtr(dfn, dfd, 0, x)
  4047. >>> fig = plt.figure()
  4048. >>> ax = fig.add_subplot(111)
  4049. >>> ax.plot(x, ncf_stats, 'b-', lw=3)
  4050. >>> ax.plot(x, ncf_special, 'r-')
  4051. >>> plt.show()
  4052. """)
  4053. add_newdoc("scipy.special", "ncfdtri",
  4054. """
  4055. ncfdtri(dfn, dfd, nc, p)
  4056. Inverse with respect to `f` of the CDF of the non-central F distribution.
  4057. See `ncfdtr` for more details.
  4058. Parameters
  4059. ----------
  4060. dfn : array_like
  4061. Degrees of freedom of the numerator sum of squares. Range (0, inf).
  4062. dfd : array_like
  4063. Degrees of freedom of the denominator sum of squares. Range (0, inf).
  4064. nc : array_like
  4065. Noncentrality parameter. Should be in range (0, 1e4).
  4066. p : array_like
  4067. Value of the cumulative distribution function. Must be in the
  4068. range [0, 1].
  4069. Returns
  4070. -------
  4071. f : float
  4072. Quantiles, i.e. the upper limit of integration.
  4073. See Also
  4074. --------
  4075. ncfdtr : CDF of the non-central F distribution.
  4076. ncfdtridfd : Inverse of `ncfdtr` with respect to `dfd`.
  4077. ncfdtridfn : Inverse of `ncfdtr` with respect to `dfn`.
  4078. ncfdtrinc : Inverse of `ncfdtr` with respect to `nc`.
  4079. Examples
  4080. --------
  4081. >>> from scipy.special import ncfdtr, ncfdtri
  4082. Compute the CDF for several values of `f`:
  4083. >>> f = [0.5, 1, 1.5]
  4084. >>> p = ncfdtr(2, 3, 1.5, f)
  4085. >>> p
  4086. array([ 0.20782291, 0.36107392, 0.47345752])
  4087. Compute the inverse. We recover the values of `f`, as expected:
  4088. >>> ncfdtri(2, 3, 1.5, p)
  4089. array([ 0.5, 1. , 1.5])
  4090. """)
  4091. add_newdoc("scipy.special", "ncfdtridfd",
  4092. """
  4093. ncfdtridfd(dfn, p, nc, f)
  4094. Calculate degrees of freedom (denominator) for the noncentral F-distribution.
  4095. This is the inverse with respect to `dfd` of `ncfdtr`.
  4096. See `ncfdtr` for more details.
  4097. Parameters
  4098. ----------
  4099. dfn : array_like
  4100. Degrees of freedom of the numerator sum of squares. Range (0, inf).
  4101. p : array_like
  4102. Value of the cumulative distribution function. Must be in the
  4103. range [0, 1].
  4104. nc : array_like
  4105. Noncentrality parameter. Should be in range (0, 1e4).
  4106. f : array_like
  4107. Quantiles, i.e. the upper limit of integration.
  4108. Returns
  4109. -------
  4110. dfd : float
  4111. Degrees of freedom of the denominator sum of squares.
  4112. See Also
  4113. --------
  4114. ncfdtr : CDF of the non-central F distribution.
  4115. ncfdtri : Quantile function; inverse of `ncfdtr` with respect to `f`.
  4116. ncfdtridfn : Inverse of `ncfdtr` with respect to `dfn`.
  4117. ncfdtrinc : Inverse of `ncfdtr` with respect to `nc`.
  4118. Notes
  4119. -----
  4120. The value of the cumulative noncentral F distribution is not necessarily
  4121. monotone in either degrees of freedom. There thus may be two values that
  4122. provide a given CDF value. This routine assumes monotonicity and will
  4123. find an arbitrary one of the two values.
  4124. Examples
  4125. --------
  4126. >>> from scipy.special import ncfdtr, ncfdtridfd
  4127. Compute the CDF for several values of `dfd`:
  4128. >>> dfd = [1, 2, 3]
  4129. >>> p = ncfdtr(2, dfd, 0.25, 15)
  4130. >>> p
  4131. array([ 0.8097138 , 0.93020416, 0.96787852])
  4132. Compute the inverse. We recover the values of `dfd`, as expected:
  4133. >>> ncfdtridfd(2, p, 0.25, 15)
  4134. array([ 1., 2., 3.])
  4135. """)
  4136. add_newdoc("scipy.special", "ncfdtridfn",
  4137. """
  4138. ncfdtridfn(p, dfd, nc, f)
  4139. Calculate degrees of freedom (numerator) for the noncentral F-distribution.
  4140. This is the inverse with respect to `dfn` of `ncfdtr`.
  4141. See `ncfdtr` for more details.
  4142. Parameters
  4143. ----------
  4144. p : array_like
  4145. Value of the cumulative distribution function. Must be in the
  4146. range [0, 1].
  4147. dfd : array_like
  4148. Degrees of freedom of the denominator sum of squares. Range (0, inf).
  4149. nc : array_like
  4150. Noncentrality parameter. Should be in range (0, 1e4).
  4151. f : float
  4152. Quantiles, i.e. the upper limit of integration.
  4153. Returns
  4154. -------
  4155. dfn : float
  4156. Degrees of freedom of the numerator sum of squares.
  4157. See Also
  4158. --------
  4159. ncfdtr : CDF of the non-central F distribution.
  4160. ncfdtri : Quantile function; inverse of `ncfdtr` with respect to `f`.
  4161. ncfdtridfd : Inverse of `ncfdtr` with respect to `dfd`.
  4162. ncfdtrinc : Inverse of `ncfdtr` with respect to `nc`.
  4163. Notes
  4164. -----
  4165. The value of the cumulative noncentral F distribution is not necessarily
  4166. monotone in either degrees of freedom. There thus may be two values that
  4167. provide a given CDF value. This routine assumes monotonicity and will
  4168. find an arbitrary one of the two values.
  4169. Examples
  4170. --------
  4171. >>> from scipy.special import ncfdtr, ncfdtridfn
  4172. Compute the CDF for several values of `dfn`:
  4173. >>> dfn = [1, 2, 3]
  4174. >>> p = ncfdtr(dfn, 2, 0.25, 15)
  4175. >>> p
  4176. array([ 0.92562363, 0.93020416, 0.93188394])
  4177. Compute the inverse. We recover the values of `dfn`, as expected:
  4178. >>> ncfdtridfn(p, 2, 0.25, 15)
  4179. array([ 1., 2., 3.])
  4180. """)
  4181. add_newdoc("scipy.special", "ncfdtrinc",
  4182. """
  4183. ncfdtrinc(dfn, dfd, p, f)
  4184. Calculate non-centrality parameter for non-central F distribution.
  4185. This is the inverse with respect to `nc` of `ncfdtr`.
  4186. See `ncfdtr` for more details.
  4187. Parameters
  4188. ----------
  4189. dfn : array_like
  4190. Degrees of freedom of the numerator sum of squares. Range (0, inf).
  4191. dfd : array_like
  4192. Degrees of freedom of the denominator sum of squares. Range (0, inf).
  4193. p : array_like
  4194. Value of the cumulative distribution function. Must be in the
  4195. range [0, 1].
  4196. f : array_like
  4197. Quantiles, i.e. the upper limit of integration.
  4198. Returns
  4199. -------
  4200. nc : float
  4201. Noncentrality parameter.
  4202. See Also
  4203. --------
  4204. ncfdtr : CDF of the non-central F distribution.
  4205. ncfdtri : Quantile function; inverse of `ncfdtr` with respect to `f`.
  4206. ncfdtridfd : Inverse of `ncfdtr` with respect to `dfd`.
  4207. ncfdtridfn : Inverse of `ncfdtr` with respect to `dfn`.
  4208. Examples
  4209. --------
  4210. >>> from scipy.special import ncfdtr, ncfdtrinc
  4211. Compute the CDF for several values of `nc`:
  4212. >>> nc = [0.5, 1.5, 2.0]
  4213. >>> p = ncfdtr(2, 3, nc, 15)
  4214. >>> p
  4215. array([ 0.96309246, 0.94327955, 0.93304098])
  4216. Compute the inverse. We recover the values of `nc`, as expected:
  4217. >>> ncfdtrinc(2, 3, p, 15)
  4218. array([ 0.5, 1.5, 2. ])
  4219. """)
  4220. add_newdoc("scipy.special", "nctdtr",
  4221. """
  4222. nctdtr(df, nc, t)
  4223. Cumulative distribution function of the non-central `t` distribution.
  4224. Parameters
  4225. ----------
  4226. df : array_like
  4227. Degrees of freedom of the distribution. Should be in range (0, inf).
  4228. nc : array_like
  4229. Noncentrality parameter. Should be in range (-1e6, 1e6).
  4230. t : array_like
  4231. Quantiles, i.e. the upper limit of integration.
  4232. Returns
  4233. -------
  4234. cdf : float or ndarray
  4235. The calculated CDF. If all inputs are scalar, the return will be a
  4236. float. Otherwise it will be an array.
  4237. See Also
  4238. --------
  4239. nctdtrit : Inverse CDF (iCDF) of the non-central t distribution.
  4240. nctdtridf : Calculate degrees of freedom, given CDF and iCDF values.
  4241. nctdtrinc : Calculate non-centrality parameter, given CDF iCDF values.
  4242. Examples
  4243. --------
  4244. >>> from scipy import special
  4245. >>> from scipy import stats
  4246. >>> import matplotlib.pyplot as plt
  4247. Plot the CDF of the non-central t distribution, for nc=0. Compare with the
  4248. t-distribution from scipy.stats:
  4249. >>> x = np.linspace(-5, 5, num=500)
  4250. >>> df = 3
  4251. >>> nct_stats = stats.t.cdf(x, df)
  4252. >>> nct_special = special.nctdtr(df, 0, x)
  4253. >>> fig = plt.figure()
  4254. >>> ax = fig.add_subplot(111)
  4255. >>> ax.plot(x, nct_stats, 'b-', lw=3)
  4256. >>> ax.plot(x, nct_special, 'r-')
  4257. >>> plt.show()
  4258. """)
  4259. add_newdoc("scipy.special", "nctdtridf",
  4260. """
  4261. nctdtridf(p, nc, t)
  4262. Calculate degrees of freedom for non-central t distribution.
  4263. See `nctdtr` for more details.
  4264. Parameters
  4265. ----------
  4266. p : array_like
  4267. CDF values, in range (0, 1].
  4268. nc : array_like
  4269. Noncentrality parameter. Should be in range (-1e6, 1e6).
  4270. t : array_like
  4271. Quantiles, i.e. the upper limit of integration.
  4272. """)
  4273. add_newdoc("scipy.special", "nctdtrinc",
  4274. """
  4275. nctdtrinc(df, p, t)
  4276. Calculate non-centrality parameter for non-central t distribution.
  4277. See `nctdtr` for more details.
  4278. Parameters
  4279. ----------
  4280. df : array_like
  4281. Degrees of freedom of the distribution. Should be in range (0, inf).
  4282. p : array_like
  4283. CDF values, in range (0, 1].
  4284. t : array_like
  4285. Quantiles, i.e. the upper limit of integration.
  4286. """)
  4287. add_newdoc("scipy.special", "nctdtrit",
  4288. """
  4289. nctdtrit(df, nc, p)
  4290. Inverse cumulative distribution function of the non-central t distribution.
  4291. See `nctdtr` for more details.
  4292. Parameters
  4293. ----------
  4294. df : array_like
  4295. Degrees of freedom of the distribution. Should be in range (0, inf).
  4296. nc : array_like
  4297. Noncentrality parameter. Should be in range (-1e6, 1e6).
  4298. p : array_like
  4299. CDF values, in range (0, 1].
  4300. """)
  4301. add_newdoc("scipy.special", "ndtr",
  4302. r"""
  4303. ndtr(x)
  4304. Gaussian cumulative distribution function.
  4305. Returns the area under the standard Gaussian probability
  4306. density function, integrated from minus infinity to `x`
  4307. .. math::
  4308. \frac{1}{\sqrt{2\pi}} \int_{-\infty}^x \exp(-t^2/2) dt
  4309. Parameters
  4310. ----------
  4311. x : array_like, real or complex
  4312. Argument
  4313. Returns
  4314. -------
  4315. ndarray
  4316. The value of the normal CDF evaluated at `x`
  4317. See Also
  4318. --------
  4319. erf
  4320. erfc
  4321. scipy.stats.norm
  4322. log_ndtr
  4323. """)
  4324. add_newdoc("scipy.special", "nrdtrimn",
  4325. """
  4326. nrdtrimn(p, x, std)
  4327. Calculate mean of normal distribution given other params.
  4328. Parameters
  4329. ----------
  4330. p : array_like
  4331. CDF values, in range (0, 1].
  4332. x : array_like
  4333. Quantiles, i.e. the upper limit of integration.
  4334. std : array_like
  4335. Standard deviation.
  4336. Returns
  4337. -------
  4338. mn : float or ndarray
  4339. The mean of the normal distribution.
  4340. See Also
  4341. --------
  4342. nrdtrimn, ndtr
  4343. """)
  4344. add_newdoc("scipy.special", "nrdtrisd",
  4345. """
  4346. nrdtrisd(p, x, mn)
  4347. Calculate standard deviation of normal distribution given other params.
  4348. Parameters
  4349. ----------
  4350. p : array_like
  4351. CDF values, in range (0, 1].
  4352. x : array_like
  4353. Quantiles, i.e. the upper limit of integration.
  4354. mn : float or ndarray
  4355. The mean of the normal distribution.
  4356. Returns
  4357. -------
  4358. std : array_like
  4359. Standard deviation.
  4360. See Also
  4361. --------
  4362. nrdtristd, ndtr
  4363. """)
  4364. add_newdoc("scipy.special", "log_ndtr",
  4365. """
  4366. log_ndtr(x)
  4367. Logarithm of Gaussian cumulative distribution function.
  4368. Returns the log of the area under the standard Gaussian probability
  4369. density function, integrated from minus infinity to `x`::
  4370. log(1/sqrt(2*pi) * integral(exp(-t**2 / 2), t=-inf..x))
  4371. Parameters
  4372. ----------
  4373. x : array_like, real or complex
  4374. Argument
  4375. Returns
  4376. -------
  4377. ndarray
  4378. The value of the log of the normal CDF evaluated at `x`
  4379. See Also
  4380. --------
  4381. erf
  4382. erfc
  4383. scipy.stats.norm
  4384. ndtr
  4385. """)
  4386. add_newdoc("scipy.special", "ndtri",
  4387. """
  4388. ndtri(y)
  4389. Inverse of `ndtr` vs x
  4390. Returns the argument x for which the area under the Gaussian
  4391. probability density function (integrated from minus infinity to `x`)
  4392. is equal to y.
  4393. """)
  4394. add_newdoc("scipy.special", "obl_ang1",
  4395. """
  4396. obl_ang1(m, n, c, x)
  4397. Oblate spheroidal angular function of the first kind and its derivative
  4398. Computes the oblate spheroidal angular function of the first kind
  4399. and its derivative (with respect to `x`) for mode parameters m>=0
  4400. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``.
  4401. Returns
  4402. -------
  4403. s
  4404. Value of the function
  4405. sp
  4406. Value of the derivative vs x
  4407. """)
  4408. add_newdoc("scipy.special", "obl_ang1_cv",
  4409. """
  4410. obl_ang1_cv(m, n, c, cv, x)
  4411. Oblate spheroidal angular function obl_ang1 for precomputed characteristic value
  4412. Computes the oblate spheroidal angular function of the first kind
  4413. and its derivative (with respect to `x`) for mode parameters m>=0
  4414. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``. Requires
  4415. pre-computed characteristic value.
  4416. Returns
  4417. -------
  4418. s
  4419. Value of the function
  4420. sp
  4421. Value of the derivative vs x
  4422. """)
  4423. add_newdoc("scipy.special", "obl_cv",
  4424. """
  4425. obl_cv(m, n, c)
  4426. Characteristic value of oblate spheroidal function
  4427. Computes the characteristic value of oblate spheroidal wave
  4428. functions of order `m`, `n` (n>=m) and spheroidal parameter `c`.
  4429. """)
  4430. add_newdoc("scipy.special", "obl_rad1",
  4431. """
  4432. obl_rad1(m, n, c, x)
  4433. Oblate spheroidal radial function of the first kind and its derivative
  4434. Computes the oblate spheroidal radial function of the first kind
  4435. and its derivative (with respect to `x`) for mode parameters m>=0
  4436. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``.
  4437. Returns
  4438. -------
  4439. s
  4440. Value of the function
  4441. sp
  4442. Value of the derivative vs x
  4443. """)
  4444. add_newdoc("scipy.special", "obl_rad1_cv",
  4445. """
  4446. obl_rad1_cv(m, n, c, cv, x)
  4447. Oblate spheroidal radial function obl_rad1 for precomputed characteristic value
  4448. Computes the oblate spheroidal radial function of the first kind
  4449. and its derivative (with respect to `x`) for mode parameters m>=0
  4450. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``. Requires
  4451. pre-computed characteristic value.
  4452. Returns
  4453. -------
  4454. s
  4455. Value of the function
  4456. sp
  4457. Value of the derivative vs x
  4458. """)
  4459. add_newdoc("scipy.special", "obl_rad2",
  4460. """
  4461. obl_rad2(m, n, c, x)
  4462. Oblate spheroidal radial function of the second kind and its derivative.
  4463. Computes the oblate spheroidal radial function of the second kind
  4464. and its derivative (with respect to `x`) for mode parameters m>=0
  4465. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``.
  4466. Returns
  4467. -------
  4468. s
  4469. Value of the function
  4470. sp
  4471. Value of the derivative vs x
  4472. """)
  4473. add_newdoc("scipy.special", "obl_rad2_cv",
  4474. """
  4475. obl_rad2_cv(m, n, c, cv, x)
  4476. Oblate spheroidal radial function obl_rad2 for precomputed characteristic value
  4477. Computes the oblate spheroidal radial function of the second kind
  4478. and its derivative (with respect to `x`) for mode parameters m>=0
  4479. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``. Requires
  4480. pre-computed characteristic value.
  4481. Returns
  4482. -------
  4483. s
  4484. Value of the function
  4485. sp
  4486. Value of the derivative vs x
  4487. """)
  4488. add_newdoc("scipy.special", "pbdv",
  4489. """
  4490. pbdv(v, x)
  4491. Parabolic cylinder function D
  4492. Returns (d, dp) the parabolic cylinder function Dv(x) in d and the
  4493. derivative, Dv'(x) in dp.
  4494. Returns
  4495. -------
  4496. d
  4497. Value of the function
  4498. dp
  4499. Value of the derivative vs x
  4500. """)
  4501. add_newdoc("scipy.special", "pbvv",
  4502. """
  4503. pbvv(v, x)
  4504. Parabolic cylinder function V
  4505. Returns the parabolic cylinder function Vv(x) in v and the
  4506. derivative, Vv'(x) in vp.
  4507. Returns
  4508. -------
  4509. v
  4510. Value of the function
  4511. vp
  4512. Value of the derivative vs x
  4513. """)
  4514. add_newdoc("scipy.special", "pbwa",
  4515. r"""
  4516. pbwa(a, x)
  4517. Parabolic cylinder function W.
  4518. The function is a particular solution to the differential equation
  4519. .. math::
  4520. y'' + \left(\frac{1}{4}x^2 - a\right)y = 0,
  4521. for a full definition see section 12.14 in [1]_.
  4522. Parameters
  4523. ----------
  4524. a : array_like
  4525. Real parameter
  4526. x : array_like
  4527. Real argument
  4528. Returns
  4529. -------
  4530. w : scalar or ndarray
  4531. Value of the function
  4532. wp : scalar or ndarray
  4533. Value of the derivative in x
  4534. Notes
  4535. -----
  4536. The function is a wrapper for a Fortran routine by Zhang and Jin
  4537. [2]_. The implementation is accurate only for ``|a|, |x| < 5`` and
  4538. returns NaN outside that range.
  4539. References
  4540. ----------
  4541. .. [1] Digital Library of Mathematical Functions, 14.30.
  4542. https://dlmf.nist.gov/14.30
  4543. .. [2] Zhang, Shanjie and Jin, Jianming. "Computation of Special
  4544. Functions", John Wiley and Sons, 1996.
  4545. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
  4546. """)
  4547. add_newdoc("scipy.special", "pdtr",
  4548. """
  4549. pdtr(k, m)
  4550. Poisson cumulative distribution function
  4551. Returns the sum of the first `k` terms of the Poisson distribution:
  4552. sum(exp(-m) * m**j / j!, j=0..k) = gammaincc( k+1, m). Arguments
  4553. must both be positive and `k` an integer.
  4554. """)
  4555. add_newdoc("scipy.special", "pdtrc",
  4556. """
  4557. pdtrc(k, m)
  4558. Poisson survival function
  4559. Returns the sum of the terms from k+1 to infinity of the Poisson
  4560. distribution: sum(exp(-m) * m**j / j!, j=k+1..inf) = gammainc(
  4561. k+1, m). Arguments must both be positive and `k` an integer.
  4562. """)
  4563. add_newdoc("scipy.special", "pdtri",
  4564. """
  4565. pdtri(k, y)
  4566. Inverse to `pdtr` vs m
  4567. Returns the Poisson variable `m` such that the sum from 0 to `k` of
  4568. the Poisson density is equal to the given probability `y`:
  4569. calculated by gammaincinv(k+1, y). `k` must be a nonnegative
  4570. integer and `y` between 0 and 1.
  4571. """)
  4572. add_newdoc("scipy.special", "pdtrik",
  4573. """
  4574. pdtrik(p, m)
  4575. Inverse to `pdtr` vs k
  4576. Returns the quantile k such that ``pdtr(k, m) = p``
  4577. """)
  4578. add_newdoc("scipy.special", "poch",
  4579. r"""
  4580. poch(z, m)
  4581. Rising factorial (z)_m
  4582. The Pochhammer symbol (rising factorial), is defined as
  4583. .. math::
  4584. (z)_m = \frac{\Gamma(z + m)}{\Gamma(z)}
  4585. For positive integer `m` it reads
  4586. .. math::
  4587. (z)_m = z (z + 1) ... (z + m - 1)
  4588. Parameters
  4589. ----------
  4590. z : array_like
  4591. (int or float)
  4592. m : array_like
  4593. (int or float)
  4594. Returns
  4595. -------
  4596. poch : ndarray
  4597. The value of the function.
  4598. """)
  4599. add_newdoc("scipy.special", "pro_ang1",
  4600. """
  4601. pro_ang1(m, n, c, x)
  4602. Prolate spheroidal angular function of the first kind and its derivative
  4603. Computes the prolate spheroidal angular function of the first kind
  4604. and its derivative (with respect to `x`) for mode parameters m>=0
  4605. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``.
  4606. Returns
  4607. -------
  4608. s
  4609. Value of the function
  4610. sp
  4611. Value of the derivative vs x
  4612. """)
  4613. add_newdoc("scipy.special", "pro_ang1_cv",
  4614. """
  4615. pro_ang1_cv(m, n, c, cv, x)
  4616. Prolate spheroidal angular function pro_ang1 for precomputed characteristic value
  4617. Computes the prolate spheroidal angular function of the first kind
  4618. and its derivative (with respect to `x`) for mode parameters m>=0
  4619. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``. Requires
  4620. pre-computed characteristic value.
  4621. Returns
  4622. -------
  4623. s
  4624. Value of the function
  4625. sp
  4626. Value of the derivative vs x
  4627. """)
  4628. add_newdoc("scipy.special", "pro_cv",
  4629. """
  4630. pro_cv(m, n, c)
  4631. Characteristic value of prolate spheroidal function
  4632. Computes the characteristic value of prolate spheroidal wave
  4633. functions of order `m`, `n` (n>=m) and spheroidal parameter `c`.
  4634. """)
  4635. add_newdoc("scipy.special", "pro_rad1",
  4636. """
  4637. pro_rad1(m, n, c, x)
  4638. Prolate spheroidal radial function of the first kind and its derivative
  4639. Computes the prolate spheroidal radial function of the first kind
  4640. and its derivative (with respect to `x`) for mode parameters m>=0
  4641. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``.
  4642. Returns
  4643. -------
  4644. s
  4645. Value of the function
  4646. sp
  4647. Value of the derivative vs x
  4648. """)
  4649. add_newdoc("scipy.special", "pro_rad1_cv",
  4650. """
  4651. pro_rad1_cv(m, n, c, cv, x)
  4652. Prolate spheroidal radial function pro_rad1 for precomputed characteristic value
  4653. Computes the prolate spheroidal radial function of the first kind
  4654. and its derivative (with respect to `x`) for mode parameters m>=0
  4655. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``. Requires
  4656. pre-computed characteristic value.
  4657. Returns
  4658. -------
  4659. s
  4660. Value of the function
  4661. sp
  4662. Value of the derivative vs x
  4663. """)
  4664. add_newdoc("scipy.special", "pro_rad2",
  4665. """
  4666. pro_rad2(m, n, c, x)
  4667. Prolate spheroidal radial function of the second kind and its derivative
  4668. Computes the prolate spheroidal radial function of the second kind
  4669. and its derivative (with respect to `x`) for mode parameters m>=0
  4670. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``.
  4671. Returns
  4672. -------
  4673. s
  4674. Value of the function
  4675. sp
  4676. Value of the derivative vs x
  4677. """)
  4678. add_newdoc("scipy.special", "pro_rad2_cv",
  4679. """
  4680. pro_rad2_cv(m, n, c, cv, x)
  4681. Prolate spheroidal radial function pro_rad2 for precomputed characteristic value
  4682. Computes the prolate spheroidal radial function of the second kind
  4683. and its derivative (with respect to `x`) for mode parameters m>=0
  4684. and n>=m, spheroidal parameter `c` and ``|x| < 1.0``. Requires
  4685. pre-computed characteristic value.
  4686. Returns
  4687. -------
  4688. s
  4689. Value of the function
  4690. sp
  4691. Value of the derivative vs x
  4692. """)
  4693. add_newdoc("scipy.special", "pseudo_huber",
  4694. r"""
  4695. pseudo_huber(delta, r)
  4696. Pseudo-Huber loss function.
  4697. .. math:: \mathrm{pseudo\_huber}(\delta, r) = \delta^2 \left( \sqrt{ 1 + \left( \frac{r}{\delta} \right)^2 } - 1 \right)
  4698. Parameters
  4699. ----------
  4700. delta : ndarray
  4701. Input array, indicating the soft quadratic vs. linear loss changepoint.
  4702. r : ndarray
  4703. Input array, possibly representing residuals.
  4704. Returns
  4705. -------
  4706. res : ndarray
  4707. The computed Pseudo-Huber loss function values.
  4708. Notes
  4709. -----
  4710. This function is convex in :math:`r`.
  4711. .. versionadded:: 0.15.0
  4712. """)
  4713. add_newdoc("scipy.special", "psi",
  4714. """
  4715. psi(z, out=None)
  4716. The digamma function.
  4717. The logarithmic derivative of the gamma function evaluated at ``z``.
  4718. Parameters
  4719. ----------
  4720. z : array_like
  4721. Real or complex argument.
  4722. out : ndarray, optional
  4723. Array for the computed values of ``psi``.
  4724. Returns
  4725. -------
  4726. digamma : ndarray
  4727. Computed values of ``psi``.
  4728. Notes
  4729. -----
  4730. For large values not close to the negative real axis ``psi`` is
  4731. computed using the asymptotic series (5.11.2) from [1]_. For small
  4732. arguments not close to the negative real axis the recurrence
  4733. relation (5.5.2) from [1]_ is used until the argument is large
  4734. enough to use the asymptotic series. For values close to the
  4735. negative real axis the reflection formula (5.5.4) from [1]_ is
  4736. used first. Note that ``psi`` has a family of zeros on the
  4737. negative real axis which occur between the poles at nonpositive
  4738. integers. Around the zeros the reflection formula suffers from
  4739. cancellation and the implementation loses precision. The sole
  4740. positive zero and the first negative zero, however, are handled
  4741. separately by precomputing series expansions using [2]_, so the
  4742. function should maintain full accuracy around the origin.
  4743. References
  4744. ----------
  4745. .. [1] NIST Digital Library of Mathematical Functions
  4746. https://dlmf.nist.gov/5
  4747. .. [2] Fredrik Johansson and others.
  4748. "mpmath: a Python library for arbitrary-precision floating-point arithmetic"
  4749. (Version 0.19) http://mpmath.org/
  4750. """)
  4751. add_newdoc("scipy.special", "radian",
  4752. """
  4753. radian(d, m, s)
  4754. Convert from degrees to radians
  4755. Returns the angle given in (d)egrees, (m)inutes, and (s)econds in
  4756. radians.
  4757. """)
  4758. add_newdoc("scipy.special", "rel_entr",
  4759. r"""
  4760. rel_entr(x, y)
  4761. Elementwise function for computing relative entropy.
  4762. .. math:: \mathrm{rel\_entr}(x, y) = \begin{cases} x \log(x / y) & x > 0, y > 0 \\ 0 & x = 0, y \ge 0 \\ \infty & \text{otherwise} \end{cases}
  4763. Parameters
  4764. ----------
  4765. x : ndarray
  4766. First input array.
  4767. y : ndarray
  4768. Second input array.
  4769. Returns
  4770. -------
  4771. res : ndarray
  4772. Output array.
  4773. See Also
  4774. --------
  4775. entr, kl_div
  4776. Notes
  4777. -----
  4778. This function is jointly convex in x and y.
  4779. .. versionadded:: 0.15.0
  4780. """)
  4781. add_newdoc("scipy.special", "rgamma",
  4782. """
  4783. rgamma(z)
  4784. Gamma function inverted
  4785. Returns ``1/gamma(x)``
  4786. """)
  4787. add_newdoc("scipy.special", "round",
  4788. """
  4789. round(x)
  4790. Round to nearest integer
  4791. Returns the nearest integer to `x` as a double precision floating
  4792. point result. If `x` ends in 0.5 exactly, the nearest even integer
  4793. is chosen.
  4794. """)
  4795. add_newdoc("scipy.special", "shichi",
  4796. r"""
  4797. shichi(x, out=None)
  4798. Hyperbolic sine and cosine integrals.
  4799. The hyperbolic sine integral is
  4800. .. math::
  4801. \int_0^x \frac{\sinh{t}}{t}dt
  4802. and the hyperbolic cosine integral is
  4803. .. math::
  4804. \gamma + \log(x) + \int_0^x \frac{\cosh{t} - 1}{t} dt
  4805. where :math:`\gamma` is Euler's constant and :math:`\log` is the
  4806. principle branch of the logarithm.
  4807. Parameters
  4808. ----------
  4809. x : array_like
  4810. Real or complex points at which to compute the hyperbolic sine
  4811. and cosine integrals.
  4812. Returns
  4813. -------
  4814. si : ndarray
  4815. Hyperbolic sine integral at ``x``
  4816. ci : ndarray
  4817. Hyperbolic cosine integral at ``x``
  4818. Notes
  4819. -----
  4820. For real arguments with ``x < 0``, ``chi`` is the real part of the
  4821. hyperbolic cosine integral. For such points ``chi(x)`` and ``chi(x
  4822. + 0j)`` differ by a factor of ``1j*pi``.
  4823. For real arguments the function is computed by calling Cephes'
  4824. [1]_ *shichi* routine. For complex arguments the algorithm is based
  4825. on Mpmath's [2]_ *shi* and *chi* routines.
  4826. References
  4827. ----------
  4828. .. [1] Cephes Mathematical Functions Library,
  4829. http://www.netlib.org/cephes/
  4830. .. [2] Fredrik Johansson and others.
  4831. "mpmath: a Python library for arbitrary-precision floating-point arithmetic"
  4832. (Version 0.19) http://mpmath.org/
  4833. """)
  4834. add_newdoc("scipy.special", "sici",
  4835. r"""
  4836. sici(x, out=None)
  4837. Sine and cosine integrals.
  4838. The sine integral is
  4839. .. math::
  4840. \int_0^x \frac{\sin{t}}{t}dt
  4841. and the cosine integral is
  4842. .. math::
  4843. \gamma + \log(x) + \int_0^x \frac{\cos{t} - 1}{t}dt
  4844. where :math:`\gamma` is Euler's constant and :math:`\log` is the
  4845. principle branch of the logarithm.
  4846. Parameters
  4847. ----------
  4848. x : array_like
  4849. Real or complex points at which to compute the sine and cosine
  4850. integrals.
  4851. Returns
  4852. -------
  4853. si : ndarray
  4854. Sine integral at ``x``
  4855. ci : ndarray
  4856. Cosine integral at ``x``
  4857. Notes
  4858. -----
  4859. For real arguments with ``x < 0``, ``ci`` is the real part of the
  4860. cosine integral. For such points ``ci(x)`` and ``ci(x + 0j)``
  4861. differ by a factor of ``1j*pi``.
  4862. For real arguments the function is computed by calling Cephes'
  4863. [1]_ *sici* routine. For complex arguments the algorithm is based
  4864. on Mpmath's [2]_ *si* and *ci* routines.
  4865. References
  4866. ----------
  4867. .. [1] Cephes Mathematical Functions Library,
  4868. http://www.netlib.org/cephes/
  4869. .. [2] Fredrik Johansson and others.
  4870. "mpmath: a Python library for arbitrary-precision floating-point arithmetic"
  4871. (Version 0.19) http://mpmath.org/
  4872. """)
  4873. add_newdoc("scipy.special", "sindg",
  4874. """
  4875. sindg(x)
  4876. Sine of angle given in degrees
  4877. """)
  4878. add_newdoc("scipy.special", "smirnov",
  4879. r"""
  4880. smirnov(n, d)
  4881. Kolmogorov-Smirnov complementary cumulative distribution function
  4882. Returns the exact Kolmogorov-Smirnov complementary cumulative
  4883. distribution function,(aka the Survival Function) of Dn+ (or Dn-)
  4884. for a one-sided test of equality between an empirical and a
  4885. theoretical distribution. It is equal to the probability that the
  4886. maximum difference between a theoretical distribution and an empirical
  4887. one based on `n` samples is greater than d.
  4888. Parameters
  4889. ----------
  4890. n : int
  4891. Number of samples
  4892. d : float array_like
  4893. Deviation between the Empirical CDF (ECDF) and the target CDF.
  4894. Returns
  4895. -------
  4896. float
  4897. The value(s) of smirnov(n, d), Prob(Dn+ >= d) (Also Prob(Dn- >= d))
  4898. Notes
  4899. -----
  4900. `smirnov` is used by `stats.kstest` in the application of the
  4901. Kolmogorov-Smirnov Goodness of Fit test. For historial reasons this
  4902. function is exposed in `scpy.special`, but the recommended way to achieve
  4903. the most accurate CDF/SF/PDF/PPF/ISF computations is to use the
  4904. `stats.ksone` distrubution.
  4905. See Also
  4906. --------
  4907. smirnovi : The Inverse Survival Function for the distribution
  4908. scipy.stats.ksone : Provides the functionality as a continuous distribution
  4909. kolmogorov, kolmogi : Functions for the two-sided distribution
  4910. Examples
  4911. --------
  4912. >>> from scipy.special import smirnov
  4913. Show the probability of a gap at least as big as 0, 0.5 and 1.0 for a sample of size 5
  4914. >>> smirnov(5, [0, 0.5, 1.0])
  4915. array([ 1. , 0.056, 0. ])
  4916. Compare a sample of size 5 drawn from a source N(0.5, 1) distribution against
  4917. a target N(0, 1) CDF.
  4918. >>> from scipy.stats import norm
  4919. >>> n = 5
  4920. >>> gendist = norm(0.5, 1) # Normal distribution, mean 0.5, stddev 1
  4921. >>> np.random.seed(seed=233423) # Set the seed for reproducibility
  4922. >>> x = np.sort(gendist.rvs(size=n))
  4923. >>> x
  4924. array([-0.20946287, 0.71688765, 0.95164151, 1.44590852, 3.08880533])
  4925. >>> target = norm(0, 1)
  4926. >>> cdfs = target.cdf(x)
  4927. >>> cdfs
  4928. array([ 0.41704346, 0.76327829, 0.82936059, 0.92589857, 0.99899518])
  4929. # Construct the Empirical CDF and the K-S statistics (Dn+, Dn-, Dn)
  4930. >>> ecdfs = np.arange(n+1, dtype=float)/n
  4931. >>> cols = np.column_stack([x, ecdfs[1:], cdfs, cdfs - ecdfs[:n], ecdfs[1:] - cdfs])
  4932. >>> np.set_printoptions(precision=3)
  4933. >>> cols
  4934. array([[ -2.095e-01, 2.000e-01, 4.170e-01, 4.170e-01, -2.170e-01],
  4935. [ 7.169e-01, 4.000e-01, 7.633e-01, 5.633e-01, -3.633e-01],
  4936. [ 9.516e-01, 6.000e-01, 8.294e-01, 4.294e-01, -2.294e-01],
  4937. [ 1.446e+00, 8.000e-01, 9.259e-01, 3.259e-01, -1.259e-01],
  4938. [ 3.089e+00, 1.000e+00, 9.990e-01, 1.990e-01, 1.005e-03]])
  4939. >>> gaps = cols[:, -2:]
  4940. >>> Dnpm = np.max(gaps, axis=0)
  4941. >>> print('Dn-=%f, Dn+=%f' % (Dnpm[0], Dnpm[1]))
  4942. Dn-=0.563278, Dn+=0.001005
  4943. >>> probs = smirnov(n, Dnpm)
  4944. >>> print(chr(10).join(['For a sample of size %d drawn from a N(0, 1) distribution:' % n,
  4945. ... ' Smirnov n=%d: Prob(Dn- >= %f) = %.4f' % (n, Dnpm[0], probs[0]),
  4946. ... ' Smirnov n=%d: Prob(Dn+ >= %f) = %.4f' % (n, Dnpm[1], probs[1])]))
  4947. For a sample of size 5 drawn from a N(0, 1) distribution:
  4948. Smirnov n=5: Prob(Dn- >= 0.563278) = 0.0250
  4949. Smirnov n=5: Prob(Dn+ >= 0.001005) = 0.9990
  4950. Plot the Empirical CDF against the target N(0, 1) CDF
  4951. >>> import matplotlib.pyplot as plt
  4952. >>> plt.step(np.concatenate([[-3], x]), ecdfs, where='post', label='Empirical CDF')
  4953. >>> x3 = np.linspace(-3, 3, 100)
  4954. >>> plt.plot(x3, target.cdf(x3), label='CDF for N(0, 1)')
  4955. >>> plt.ylim([0, 1]); plt.grid(True); plt.legend();
  4956. # Add vertical lines marking Dn+ and Dn-
  4957. >>> iminus, iplus = np.argmax(gaps, axis=0)
  4958. >>> plt.vlines([x[iminus]], ecdfs[iminus], cdfs[iminus], color='r', linestyle='dashed', lw=4)
  4959. >>> plt.vlines([x[iplus]], cdfs[iplus], ecdfs[iplus+1], color='m', linestyle='dashed', lw=4)
  4960. >>> plt.show()
  4961. """)
  4962. add_newdoc("scipy.special", "smirnovi",
  4963. """
  4964. smirnovi(n, p)
  4965. Inverse to `smirnov`
  4966. Returns `d` such that ``smirnov(n, d) == p``, the critical value
  4967. corresponding to `p`.
  4968. Parameters
  4969. ----------
  4970. n : int
  4971. Number of samples
  4972. p : float array_like
  4973. Probability
  4974. Returns
  4975. -------
  4976. float
  4977. The value(s) of smirnovi(n, p), the critical values.
  4978. Notes
  4979. -----
  4980. `smirnov` is used by `stats.kstest` in the application of the
  4981. Kolmogorov-Smirnov Goodness of Fit test. For historial reasons this
  4982. function is exposed in `scpy.special`, but the recommended way to achieve
  4983. the most accurate CDF/SF/PDF/PPF/ISF computations is to use the
  4984. `stats.ksone` distrubution.
  4985. See Also
  4986. --------
  4987. smirnov : The Survival Function (SF) for the distribution
  4988. scipy.stats.ksone : Provides the functionality as a continuous distribution
  4989. kolmogorov, kolmogi, scipy.stats.kstwobign : Functions for the two-sided distribution
  4990. """)
  4991. add_newdoc("scipy.special", "_smirnovc",
  4992. """
  4993. _smirnovc(n, d)
  4994. Internal function, do not use.
  4995. """)
  4996. add_newdoc("scipy.special", "_smirnovci",
  4997. """
  4998. Internal function, do not use.
  4999. """)
  5000. add_newdoc("scipy.special", "_smirnovp",
  5001. """
  5002. _smirnovp(n, p)
  5003. Internal function, do not use.
  5004. """)
  5005. add_newdoc("scipy.special", "spence",
  5006. r"""
  5007. spence(z, out=None)
  5008. Spence's function, also known as the dilogarithm.
  5009. It is defined to be
  5010. .. math::
  5011. \int_0^z \frac{\log(t)}{1 - t}dt
  5012. for complex :math:`z`, where the contour of integration is taken
  5013. to avoid the branch cut of the logarithm. Spence's function is
  5014. analytic everywhere except the negative real axis where it has a
  5015. branch cut.
  5016. Parameters
  5017. ----------
  5018. z : array_like
  5019. Points at which to evaluate Spence's function
  5020. Returns
  5021. -------
  5022. s : ndarray
  5023. Computed values of Spence's function
  5024. Notes
  5025. -----
  5026. There is a different convention which defines Spence's function by
  5027. the integral
  5028. .. math::
  5029. -\int_0^z \frac{\log(1 - t)}{t}dt;
  5030. this is our ``spence(1 - z)``.
  5031. """)
  5032. add_newdoc("scipy.special", "stdtr",
  5033. """
  5034. stdtr(df, t)
  5035. Student t distribution cumulative density function
  5036. Returns the integral from minus infinity to t of the Student t
  5037. distribution with df > 0 degrees of freedom::
  5038. gamma((df+1)/2)/(sqrt(df*pi)*gamma(df/2)) *
  5039. integral((1+x**2/df)**(-df/2-1/2), x=-inf..t)
  5040. """)
  5041. add_newdoc("scipy.special", "stdtridf",
  5042. """
  5043. stdtridf(p, t)
  5044. Inverse of `stdtr` vs df
  5045. Returns the argument df such that stdtr(df, t) is equal to `p`.
  5046. """)
  5047. add_newdoc("scipy.special", "stdtrit",
  5048. """
  5049. stdtrit(df, p)
  5050. Inverse of `stdtr` vs `t`
  5051. Returns the argument `t` such that stdtr(df, t) is equal to `p`.
  5052. """)
  5053. add_newdoc("scipy.special", "struve",
  5054. r"""
  5055. struve(v, x)
  5056. Struve function.
  5057. Return the value of the Struve function of order `v` at `x`. The Struve
  5058. function is defined as,
  5059. .. math::
  5060. H_v(x) = (z/2)^{v + 1} \sum_{n=0}^\infty \frac{(-1)^n (z/2)^{2n}}{\Gamma(n + \frac{3}{2}) \Gamma(n + v + \frac{3}{2})},
  5061. where :math:`\Gamma` is the gamma function.
  5062. Parameters
  5063. ----------
  5064. v : array_like
  5065. Order of the Struve function (float).
  5066. x : array_like
  5067. Argument of the Struve function (float; must be positive unless `v` is
  5068. an integer).
  5069. Returns
  5070. -------
  5071. H : ndarray
  5072. Value of the Struve function of order `v` at `x`.
  5073. Notes
  5074. -----
  5075. Three methods discussed in [1]_ are used to evaluate the Struve function:
  5076. - power series
  5077. - expansion in Bessel functions (if :math:`|z| < |v| + 20`)
  5078. - asymptotic large-z expansion (if :math:`z \geq 0.7v + 12`)
  5079. Rounding errors are estimated based on the largest terms in the sums, and
  5080. the result associated with the smallest error is returned.
  5081. See also
  5082. --------
  5083. modstruve
  5084. References
  5085. ----------
  5086. .. [1] NIST Digital Library of Mathematical Functions
  5087. https://dlmf.nist.gov/11
  5088. """)
  5089. add_newdoc("scipy.special", "tandg",
  5090. """
  5091. tandg(x)
  5092. Tangent of angle x given in degrees.
  5093. """)
  5094. add_newdoc("scipy.special", "tklmbda",
  5095. """
  5096. tklmbda(x, lmbda)
  5097. Tukey-Lambda cumulative distribution function
  5098. """)
  5099. add_newdoc("scipy.special", "wofz",
  5100. """
  5101. wofz(z)
  5102. Faddeeva function
  5103. Returns the value of the Faddeeva function for complex argument::
  5104. exp(-z**2) * erfc(-i*z)
  5105. See Also
  5106. --------
  5107. dawsn, erf, erfc, erfcx, erfi
  5108. References
  5109. ----------
  5110. .. [1] Steven G. Johnson, Faddeeva W function implementation.
  5111. http://ab-initio.mit.edu/Faddeeva
  5112. Examples
  5113. --------
  5114. >>> from scipy import special
  5115. >>> import matplotlib.pyplot as plt
  5116. >>> x = np.linspace(-3, 3)
  5117. >>> z = special.wofz(x)
  5118. >>> plt.plot(x, z.real, label='wofz(x).real')
  5119. >>> plt.plot(x, z.imag, label='wofz(x).imag')
  5120. >>> plt.xlabel('$x$')
  5121. >>> plt.legend(framealpha=1, shadow=True)
  5122. >>> plt.grid(alpha=0.25)
  5123. >>> plt.show()
  5124. """)
  5125. add_newdoc("scipy.special", "xlogy",
  5126. """
  5127. xlogy(x, y)
  5128. Compute ``x*log(y)`` so that the result is 0 if ``x = 0``.
  5129. Parameters
  5130. ----------
  5131. x : array_like
  5132. Multiplier
  5133. y : array_like
  5134. Argument
  5135. Returns
  5136. -------
  5137. z : array_like
  5138. Computed x*log(y)
  5139. Notes
  5140. -----
  5141. .. versionadded:: 0.13.0
  5142. """)
  5143. add_newdoc("scipy.special", "xlog1py",
  5144. """
  5145. xlog1py(x, y)
  5146. Compute ``x*log1p(y)`` so that the result is 0 if ``x = 0``.
  5147. Parameters
  5148. ----------
  5149. x : array_like
  5150. Multiplier
  5151. y : array_like
  5152. Argument
  5153. Returns
  5154. -------
  5155. z : array_like
  5156. Computed x*log1p(y)
  5157. Notes
  5158. -----
  5159. .. versionadded:: 0.13.0
  5160. """)
  5161. add_newdoc("scipy.special", "y0",
  5162. r"""
  5163. y0(x)
  5164. Bessel function of the second kind of order 0.
  5165. Parameters
  5166. ----------
  5167. x : array_like
  5168. Argument (float).
  5169. Returns
  5170. -------
  5171. Y : ndarray
  5172. Value of the Bessel function of the second kind of order 0 at `x`.
  5173. Notes
  5174. -----
  5175. The domain is divided into the intervals [0, 5] and (5, infinity). In the
  5176. first interval a rational approximation :math:`R(x)` is employed to
  5177. compute,
  5178. .. math::
  5179. Y_0(x) = R(x) + \frac{2 \log(x) J_0(x)}{\pi},
  5180. where :math:`J_0` is the Bessel function of the first kind of order 0.
  5181. In the second interval, the Hankel asymptotic expansion is employed with
  5182. two rational functions of degree 6/6 and 7/7.
  5183. This function is a wrapper for the Cephes [1]_ routine `y0`.
  5184. See also
  5185. --------
  5186. j0
  5187. yv
  5188. References
  5189. ----------
  5190. .. [1] Cephes Mathematical Functions Library,
  5191. http://www.netlib.org/cephes/
  5192. """)
  5193. add_newdoc("scipy.special", "y1",
  5194. """
  5195. y1(x)
  5196. Bessel function of the second kind of order 1.
  5197. Parameters
  5198. ----------
  5199. x : array_like
  5200. Argument (float).
  5201. Returns
  5202. -------
  5203. Y : ndarray
  5204. Value of the Bessel function of the second kind of order 1 at `x`.
  5205. Notes
  5206. -----
  5207. The domain is divided into the intervals [0, 8] and (8, infinity). In the
  5208. first interval a 25 term Chebyshev expansion is used, and computing
  5209. :math:`J_1` (the Bessel function of the first kind) is required. In the
  5210. second, the asymptotic trigonometric representation is employed using two
  5211. rational functions of degree 5/5.
  5212. This function is a wrapper for the Cephes [1]_ routine `y1`.
  5213. See also
  5214. --------
  5215. j1
  5216. yn
  5217. yv
  5218. References
  5219. ----------
  5220. .. [1] Cephes Mathematical Functions Library,
  5221. http://www.netlib.org/cephes/
  5222. """)
  5223. add_newdoc("scipy.special", "yn",
  5224. r"""
  5225. yn(n, x)
  5226. Bessel function of the second kind of integer order and real argument.
  5227. Parameters
  5228. ----------
  5229. n : array_like
  5230. Order (integer).
  5231. z : array_like
  5232. Argument (float).
  5233. Returns
  5234. -------
  5235. Y : ndarray
  5236. Value of the Bessel function, :math:`Y_n(x)`.
  5237. Notes
  5238. -----
  5239. Wrapper for the Cephes [1]_ routine `yn`.
  5240. The function is evaluated by forward recurrence on `n`, starting with
  5241. values computed by the Cephes routines `y0` and `y1`. If `n = 0` or 1,
  5242. the routine for `y0` or `y1` is called directly.
  5243. See also
  5244. --------
  5245. yv : For real order and real or complex argument.
  5246. References
  5247. ----------
  5248. .. [1] Cephes Mathematical Functions Library,
  5249. http://www.netlib.org/cephes/
  5250. """)
  5251. add_newdoc("scipy.special", "yv",
  5252. r"""
  5253. yv(v, z)
  5254. Bessel function of the second kind of real order and complex argument.
  5255. Parameters
  5256. ----------
  5257. v : array_like
  5258. Order (float).
  5259. z : array_like
  5260. Argument (float or complex).
  5261. Returns
  5262. -------
  5263. Y : ndarray
  5264. Value of the Bessel function of the second kind, :math:`Y_v(x)`.
  5265. Notes
  5266. -----
  5267. For positive `v` values, the computation is carried out using the
  5268. AMOS [1]_ `zbesy` routine, which exploits the connection to the Hankel
  5269. Bessel functions :math:`H_v^{(1)}` and :math:`H_v^{(2)}`,
  5270. .. math:: Y_v(z) = \frac{1}{2\imath} (H_v^{(1)} - H_v^{(2)}).
  5271. For negative `v` values the formula,
  5272. .. math:: Y_{-v}(z) = Y_v(z) \cos(\pi v) + J_v(z) \sin(\pi v)
  5273. is used, where :math:`J_v(z)` is the Bessel function of the first kind,
  5274. computed using the AMOS routine `zbesj`. Note that the second term is
  5275. exactly zero for integer `v`; to improve accuracy the second term is
  5276. explicitly omitted for `v` values such that `v = floor(v)`.
  5277. See also
  5278. --------
  5279. yve : :math:`Y_v` with leading exponential behavior stripped off.
  5280. References
  5281. ----------
  5282. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  5283. of a Complex Argument and Nonnegative Order",
  5284. http://netlib.org/amos/
  5285. """)
  5286. add_newdoc("scipy.special", "yve",
  5287. r"""
  5288. yve(v, z)
  5289. Exponentially scaled Bessel function of the second kind of real order.
  5290. Returns the exponentially scaled Bessel function of the second
  5291. kind of real order `v` at complex `z`::
  5292. yve(v, z) = yv(v, z) * exp(-abs(z.imag))
  5293. Parameters
  5294. ----------
  5295. v : array_like
  5296. Order (float).
  5297. z : array_like
  5298. Argument (float or complex).
  5299. Returns
  5300. -------
  5301. Y : ndarray
  5302. Value of the exponentially scaled Bessel function.
  5303. Notes
  5304. -----
  5305. For positive `v` values, the computation is carried out using the
  5306. AMOS [1]_ `zbesy` routine, which exploits the connection to the Hankel
  5307. Bessel functions :math:`H_v^{(1)}` and :math:`H_v^{(2)}`,
  5308. .. math:: Y_v(z) = \frac{1}{2\imath} (H_v^{(1)} - H_v^{(2)}).
  5309. For negative `v` values the formula,
  5310. .. math:: Y_{-v}(z) = Y_v(z) \cos(\pi v) + J_v(z) \sin(\pi v)
  5311. is used, where :math:`J_v(z)` is the Bessel function of the first kind,
  5312. computed using the AMOS routine `zbesj`. Note that the second term is
  5313. exactly zero for integer `v`; to improve accuracy the second term is
  5314. explicitly omitted for `v` values such that `v = floor(v)`.
  5315. References
  5316. ----------
  5317. .. [1] Donald E. Amos, "AMOS, A Portable Package for Bessel Functions
  5318. of a Complex Argument and Nonnegative Order",
  5319. http://netlib.org/amos/
  5320. """)
  5321. add_newdoc("scipy.special", "_zeta",
  5322. """
  5323. _zeta(x, q)
  5324. Internal function, Hurwitz zeta.
  5325. """)
  5326. add_newdoc("scipy.special", "zetac",
  5327. """
  5328. zetac(x)
  5329. Riemann zeta function minus 1.
  5330. This function is defined as
  5331. .. math:: \\zeta(x) = \\sum_{k=2}^{\\infty} 1 / k^x,
  5332. where ``x > 1``. For ``x < 1``, the analytic continuation is computed.
  5333. Because of limitations of the numerical algorithm, ``zetac(x)`` returns
  5334. `nan` for `x` less than -30.8148.
  5335. Parameters
  5336. ----------
  5337. x : array_like of float
  5338. Values at which to compute zeta(x) - 1 (must be real).
  5339. Returns
  5340. -------
  5341. out : array_like
  5342. Values of zeta(x) - 1.
  5343. See Also
  5344. --------
  5345. zeta
  5346. Examples
  5347. --------
  5348. >>> from scipy.special import zetac, zeta
  5349. Some special values:
  5350. >>> zetac(2), np.pi**2/6 - 1
  5351. (0.64493406684822641, 0.6449340668482264)
  5352. >>> zetac(-1), -1.0/12 - 1
  5353. (-1.0833333333333333, -1.0833333333333333)
  5354. Compare ``zetac(x)`` to ``zeta(x) - 1`` for large `x`:
  5355. >>> zetac(60), zeta(60) - 1
  5356. (8.673617380119933e-19, 0.0)
  5357. """)
  5358. add_newdoc("scipy.special", "_struve_asymp_large_z",
  5359. """
  5360. _struve_asymp_large_z(v, z, is_h)
  5361. Internal function for testing `struve` & `modstruve`
  5362. Evaluates using asymptotic expansion
  5363. Returns
  5364. -------
  5365. v, err
  5366. """)
  5367. add_newdoc("scipy.special", "_struve_power_series",
  5368. """
  5369. _struve_power_series(v, z, is_h)
  5370. Internal function for testing `struve` & `modstruve`
  5371. Evaluates using power series
  5372. Returns
  5373. -------
  5374. v, err
  5375. """)
  5376. add_newdoc("scipy.special", "_struve_bessel_series",
  5377. """
  5378. _struve_bessel_series(v, z, is_h)
  5379. Internal function for testing `struve` & `modstruve`
  5380. Evaluates using Bessel function series
  5381. Returns
  5382. -------
  5383. v, err
  5384. """)
  5385. add_newdoc("scipy.special", "_spherical_jn",
  5386. """
  5387. Internal function, use `spherical_jn` instead.
  5388. """)
  5389. add_newdoc("scipy.special", "_spherical_jn_d",
  5390. """
  5391. Internal function, use `spherical_jn` instead.
  5392. """)
  5393. add_newdoc("scipy.special", "_spherical_yn",
  5394. """
  5395. Internal function, use `spherical_yn` instead.
  5396. """)
  5397. add_newdoc("scipy.special", "_spherical_yn_d",
  5398. """
  5399. Internal function, use `spherical_yn` instead.
  5400. """)
  5401. add_newdoc("scipy.special", "_spherical_in",
  5402. """
  5403. Internal function, use `spherical_in` instead.
  5404. """)
  5405. add_newdoc("scipy.special", "_spherical_in_d",
  5406. """
  5407. Internal function, use `spherical_in` instead.
  5408. """)
  5409. add_newdoc("scipy.special", "_spherical_kn",
  5410. """
  5411. Internal function, use `spherical_kn` instead.
  5412. """)
  5413. add_newdoc("scipy.special", "_spherical_kn_d",
  5414. """
  5415. Internal function, use `spherical_kn` instead.
  5416. """)
  5417. add_newdoc("scipy.special", "loggamma",
  5418. r"""
  5419. loggamma(z, out=None)
  5420. Principal branch of the logarithm of the Gamma function.
  5421. Defined to be :math:`\log(\Gamma(x))` for :math:`x > 0` and
  5422. extended to the complex plane by analytic continuation. The
  5423. function has a single branch cut on the negative real axis.
  5424. .. versionadded:: 0.18.0
  5425. Parameters
  5426. ----------
  5427. z : array-like
  5428. Values in the complex plain at which to compute ``loggamma``
  5429. out : ndarray, optional
  5430. Output array for computed values of ``loggamma``
  5431. Returns
  5432. -------
  5433. loggamma : ndarray
  5434. Values of ``loggamma`` at z.
  5435. Notes
  5436. -----
  5437. It is not generally true that :math:`\log\Gamma(z) =
  5438. \log(\Gamma(z))`, though the real parts of the functions do
  5439. agree. The benefit of not defining `loggamma` as
  5440. :math:`\log(\Gamma(z))` is that the latter function has a
  5441. complicated branch cut structure whereas `loggamma` is analytic
  5442. except for on the negative real axis.
  5443. The identities
  5444. .. math::
  5445. \exp(\log\Gamma(z)) &= \Gamma(z) \\
  5446. \log\Gamma(z + 1) &= \log(z) + \log\Gamma(z)
  5447. make `loggamma` useful for working in complex logspace.
  5448. On the real line `loggamma` is related to `gammaln` via
  5449. ``exp(loggamma(x + 0j)) = gammasgn(x)*exp(gammaln(x))``, up to
  5450. rounding error.
  5451. The implementation here is based on [hare1997]_.
  5452. See also
  5453. --------
  5454. gammaln : logarithm of the absolute value of the Gamma function
  5455. gammasgn : sign of the gamma function
  5456. References
  5457. ----------
  5458. .. [hare1997] D.E.G. Hare,
  5459. *Computing the Principal Branch of log-Gamma*,
  5460. Journal of Algorithms, Volume 25, Issue 2, November 1997, pages 221-236.
  5461. """)
  5462. add_newdoc("scipy.special", "_sinpi",
  5463. """
  5464. Internal function, do not use.
  5465. """)
  5466. add_newdoc("scipy.special", "_cospi",
  5467. """
  5468. Internal function, do not use.
  5469. """)
  5470. add_newdoc("scipy.special", "owens_t",
  5471. """
  5472. owens_t(h, a)
  5473. Owen's T Function.
  5474. The function T(h, a) gives the probability of the event
  5475. (X > h and 0 < Y < a * X) where X and Y are independent
  5476. standard normal random variables.
  5477. Parameters
  5478. ----------
  5479. h: array_like
  5480. Input value.
  5481. a: array_like
  5482. Input value.
  5483. Returns
  5484. -------
  5485. t: scalar or ndarray
  5486. Probability of the event (X > h and 0 < Y < a * X),
  5487. where X and Y are independent standard normal random variables.
  5488. Examples
  5489. --------
  5490. >>> from scipy import special
  5491. >>> a = 3.5
  5492. >>> h = 0.78
  5493. >>> special.owens_t(h, a)
  5494. 0.10877216734852274
  5495. References
  5496. ----------
  5497. .. [1] M. Patefield and D. Tandy, "Fast and accurate calculation of
  5498. Owen's T Function", Statistical Software vol. 5, pp. 1-25, 2000.
  5499. """)