Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:31:29+00:00 2026-06-03T22:31:29+00:00

I made a function to take intergal Likehood(L,U,gamma,sigma), but there are some error. Here

  • 0

I made a function to take intergal Likehood(L,U,gamma,sigma), but there are some error.
Here is my Matlab code.

function func=Likelihook(L,U,gamma,sigma)
Lstar=3;
Ustar=20;
gammastar=1.5;
a=0.2;
func=-0.5.*log(2.*pi)-log(sigma)+log(gamma)-log(L.^(-gamma)-U.^(-gamma))+quad(@(y)(log(quad(@(x)(x.^(-gamma-1).*exp(-0.5.*((y-x)./sigma).^2)),L,U)).*gammastar./(sqrt(2*pi).*Lstar.^(-gammastar)-Ustar.^(-gammastar)).*quad(@(x)(x.^(-gammastar-1)./(a.*x).*exp(-0.5.*((y-x)./(a.*x)).^2)),Lstar,Ustar)),-inf,inf) ;

And here is the function i want calculate

https://i.stack.imgur.com/lP1lz.png

Anyone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:31:30+00:00Added an answer on June 3, 2026 at 10:31 pm

    Explanation

    Matlab tries to compute the integration vectorially, so

    f = @(x) x;
    quad(f(x) x,1,5)
    

    gets evaluated like

    sum(f(1:dx:5))
    

    with matlab figuring out what the discretization interval should be.
    This is computable, because f = @(x) x takes vectorial input.

    When you have a double integral, you’ll get something like this:

    f = @(x,y) x+y;
    quad(quad(f(x,y) x,1,5),4:10)
    

    becomes

    sum(sum(f(1:dx:5,),4:dy:10))
    

    This will only evaluate if 1:dx:5 and 4:dy:10 happen to have the same number of elements (not very likely).

    Solution

    You can solve it of course, by adapting your function f so it does take any two vectors as an input, for example by using arrayfun.

    For your problem, this is done like this:

    func = -0.5.*log(2.*pi)-log(sigma)+log(gamma)-log(L.^(-gamma)-U.^(-gamma)) ...
    +quad(@(y)( ...
        log( arrayfun(@(z) quad(@(x)( x.^(-gamma-1).*exp(-0.5.*((z-x)./sigma).^2)),L,U), y) ) ...
        .* gammastar./(sqrt(2*pi).*Lstar.^(-gammastar)-Ustar.^(-gammastar)) ...
        .* arrayfun(@(z) quad(@(x)( x.^(-gammastar-1)./(a.*x).*exp(-0.5.*((z-    x)./(a.*x)).^2)),Lstar,Ustar), y) ...
    ),-inf,inf) ;
    

    I inserted some linebreaks (...) for easier reading 🙂

    Remarks

    I’m not sure if this will lead to solid results for you, because of the integration from -Inf to Inf: in the documentation of quad, it is stated that

    If the interval is infinite, [a,Inf), then for the integral of fun(x) to exist, fun(x) must decay as x approaches infinity

    so, you’ll have to make sure that this is the case, otherwise you’ll keep getting NaNs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made some function that generates an email template. Code it generates is pure
Hi have made this function which is made to replicate an error that I
I made this little function from code snippets around the net. It does what
Before I added loadItems function, $(.ActivateItem).click(function () {...}): works fine. But when I made
I wrote some code in C and I was surprised to see it take
Is it some kind of enforced rule that the overload ++ function must take
I made a program whose major function is use API to take photos and
Anyone got a ready made function that will take an XML string and return
I am trying to take some functions that I've made and tested with in
I made a function which displays date on the webpage,, and i uploaded the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.