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 8863833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:05:10+00:00 2026-06-14T16:05:10+00:00

I am searching for a function/package-name in R which allows one to separate two

  • 0

I am searching for a function/package-name in R which allows one to separate two superimposed normal distributions. The distribution looks something like this:

x<-c(3.95, 3.99, 4.0, 4.04, 4.1, 10.9, 11.5, 11.9, 11.7, 12.3)
  • 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-14T16:05:12+00:00Added an answer on June 14, 2026 at 4:05 pm

    I had good results in the past using vector generalized linear models. The VGAM package is useful for that.

    The mix2normal1 function allows to estimate the parameters of a mix of two univariate normal distributions.

    Little example

    require(VGAM)
    set.seed(12345)
    
    # Create a binormal distribution with means 10 and 20
    data <- c(rnorm(100, 10, 1.5), rnorm(200, 20, 3))
    
    # Initial parameters for minimization algorithm
    # You may want to create some logic to estimate this a priori... not always easy but possible
    # m, m2: Means - s, s2: SDs - w: relative weight of the first distribution (the second is 1-w)
    init.params <- list(m=5, m2=8, s=1, s2=1, w=0.5)
    
    fit <<- vglm(data ~ 1, mix2normal1(equalsd=FALSE), 
                    iphi=init.params$w, imu=init.params$m, imu2=init.params$m2, 
                    isd1=init.params$s, isd2=init.params$s2)
    
    # Calculated parameters
    pars = as.vector(coef(fit))
    w = logit(pars[1], inverse=TRUE)
    m1 = pars[2]
    sd1 = exp(pars[3])
    m2 = pars[4]
    sd2 = exp(pars[5])
    
    # Plot an histogram of the data
    hist(data, 30, col="black", freq=F)
    # Superimpose the fitted distribution
    x <- seq(0, 30, 0.1)
    points(x, w*dnorm(x, m1, sd1)+(1-w)*dnorm(x,m2,sd2), "l", col="red", lwd=2)
    

    This correctly gives (“true” parameters – 10, 20, 1.5, 3)

    > m1
    [1] 10.49236
    > m2
    [1] 20.06296
    > sd1
    [1] 1.792519
    > sd2
    [1] 2.877999
    

    Fit bimodal distribution

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

Sidebar

Related Questions

I'm now using a function which returns NSString after searching html, The code is
I searching function something like OpenFileDialog on .NET but on win32 , i can't
I'm going to implement a searching function for a sms managing system, where the
document.body.innerHTML works to search within the body. Is there a similar function for searching
I was searching how to pass an argument in torrent_info() function during the use
I was recently searching for a way to call the print function on a
I have a utility function in my program for searching for entities. It takes
I went as far as searching C sources, but I can't find this function,
I am trying to call a function on a unmanaged C++ DLL, searching stackoverflow
Well, I was searching for a simple collision detection function for as3, I found

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.