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

  • SEARCH
  • Home
  • 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 6013383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:32:26+00:00 2026-05-23T02:32:26+00:00

I have PDFs and CDFs for two custom distributions, a means of generating RandomVariates

  • 0

I have PDFs and CDFs for two custom distributions, a means of generating RandomVariates for each, and code for fitting parameters to data. Some of this code I’ve posted previously at:

Calculating expectation for a custom distribution in Mathematica

Some of it follows:

nlDist /: PDF[nlDist[alpha_, beta_, mu_, sigma_], 
   x_] := (1/(2*(alpha + beta)))*alpha* 
   beta*(E^(alpha*(mu + (alpha*sigma^2)/2 - x))* 
      Erfc[(mu + alpha*sigma^2 - x)/(Sqrt[2]*sigma)] + 
     E^(beta*(-mu + (beta*sigma^2)/2 + x))* 
      Erfc[(-mu + beta*sigma^2 + x)/(Sqrt[2]*sigma)]); 

nlDist /: 
  CDF[nlDist[alpha_, beta_, mu_, sigma_], 
   x_] := ((1/(2*(alpha + beta)))*((alpha + beta)*E^(alpha*x)* 
        Erfc[(mu - x)/(Sqrt[2]*sigma)] - 
       beta*E^(alpha*mu + (alpha^2*sigma^2)/2)*
        Erfc[(mu + alpha*sigma^2 - x)/(Sqrt[2]*sigma)] + 
       alpha*E^((-beta)*mu + (beta^2*sigma^2)/2 + alpha*x + beta*x)*
        Erfc[(-mu + beta*sigma^2 + x)/(Sqrt[2]*sigma)]))/ 
   E^(alpha*x);         

dplDist /: PDF[dplDist[alpha_, beta_, mu_, sigma_], x_] := 
  PDF[nlDist[alpha, beta, mu, sigma], Log[x]]/x;
dplDist /: CDF[dplDist[alpha_, beta_, mu_, sigma_], x_] := 
  CDF[nlDist[alpha, beta, mu, sigma], Log[x]];

nlDist /: DistributionDomain[nlDist[alpha_, beta_, mu_, sigma_]] := 
 Interval[{-Infinity, Infinity}]

nlDist /: 
    Random`DistributionVector[
    nlDist [alpha_, beta_, mu_, sigma_], n_, prec_] :=
    RandomVariate[ExponentialDistribution[alpha], n, 
        WorkingPrecision -> prec] - 
      RandomVariate[ExponentialDistribution[beta], n, 
        WorkingPrecision -> prec] + 
      RandomVariate[NormalDistribution[mu, sigma], n, 
        WorkingPrecision -> prec];

dplDist /: 
    Random`DistributionVector[
    dplDist[alpha_, beta_, mu_, sigma_], n_, prec_] :=
    Exp[RandomVariate[ExponentialDistribution[alpha], n, 
         WorkingPrecision -> prec] - 
       RandomVariate[ExponentialDistribution[beta], n, 
         WorkingPrecision -> prec] + 
       RandomVariate[NormalDistribution[mu, sigma], n, 
         WorkingPrecision -> prec]];

I can post more of the code if someone needs to see it, but I think the above gives a good sense of the approach so far.

Now I need a way to use DistributionFitTest[] with these distributions in something like this:

DistributionFitTest[data, dplDist[3.77, 1.34, -2.65, 0.40],"HypothesisTestData"]  

Ah, but this doesn’t work. Instead I get an error message that starts out as:

“The argument
dplDist[3.77,1.34,-2.65,0.4] should be
a valid distribution…”

So it appears that DistributionFitTest[] doesn’t recognize these distributions as distributions.

I don’t see how using TagSet would help in this instance, unless one can use TagSet to give DistributionFitTest[] what it needs to identify these custom distributions.

Can anyone advise me of a way to get this to work? I’d like to use DistributionFitTest[] with custom distributions like this or find some work around to assess goodness of fit.

Thx — Jagra

  • 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-05-23T02:32:27+00:00Added an answer on May 23, 2026 at 2:32 am

    Since this question has come up many times, I think it’s prime time to furnish some recipes for how to properly cook a custom distribution for v8.

    Use TagSet to define for your distribution:

    1. DistributionParameterQ, DistributionParameterAssumptions, DistributionDomain
    2. Define PDF, CDF, SurvivalFunction, HazardFunction
    3. Define random number generation code by coding Random`DistributionVector

    Doing so will make everything but parameter estimation work for your distribution.

    Your mistake was that dplDist had no DistributionDomain definition, and both nlDist and dplDist did not have
    DistributionParameterQ and DistributionParameterAssumptions definitions.

    I added to your definitions the following:

    dplDist /: DistributionDomain[dplDist[alpha_, beta_, mu_, sigma_]] := 
     Interval[{-Infinity, Infinity}]
    
    nlDist /: 
     DistributionParameterQ[nlDist[alpha_, beta_, mu_, sigma_]] := ! 
      TrueQ[Not[
        Element[{alpha, beta, sigma, mu}, Reals] && alpha > 0 && 
         beta > 0 && sigma > 0]]
    
    dplDist /: 
     DistributionParameterQ[dplDist[alpha_, beta_, mu_, sigma_]] := ! 
      TrueQ[Not[
        Element[{alpha, beta, sigma, mu}, Reals] && alpha > 0 && 
         beta > 0 && sigma > 0]]
    
    nlDist /: 
     DistributionParameterAssumptions[
      nlDist[alpha_, beta_, mu_, sigma_]] := 
     Element[{alpha, beta, sigma, mu}, Reals] && alpha > 0 && beta > 0 && 
      sigma > 0
    
    dplDist /: 
     DistributionParameterAssumptions[
      dplDist[alpha_, beta_, mu_, sigma_]] := 
     Element[{alpha, beta, sigma, mu}, Reals] && alpha > 0 && beta > 0 && 
      sigma > 0
    

    And now it worked:

    In[1014]:= data = RandomVariate[dplDist[3.77, 1.34, -2.65, 0.40], 100];
    
    In[1015]:= DistributionFitTest[data, dplDist[3.77, 1.34, -2.65, 0.40],
      "HypothesisTestData"]
    
    Out[1015]= HypothesisTestData[<<DistributionFitTest>>]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tableview which contains custom cells where each cell has some PDF
I am to process single PDFs that have each been created by 'merging' multiple
I have two PDFs that are made on the fly using Prawn PDF. The
I have a MonoTouch application that generates some PDFs locally and then prints them
I have the following code. It's used to combine various image attachments (and pdfs)
I have upgraded a SharePoint, excatly same code, but now links to pdfs always
I have some scripts I'd like to run each morning at 6am. These scripts
I have a spring mvc application and I am rendering some pdfs using classes
I have two UIWebViews, one to handle normal files and one to handle PDFs
I have to print out some PDFs for a project at work. Is there

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.