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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:38:02+00:00 2026-05-28T01:38:02+00:00

I am looking for any script (preferably Python) to calculate the two dimensional normal

  • 0

I am looking for any script (preferably Python) to calculate the two dimensional normal distribution function of series of three dimensional data. If one does not exist, I would appreciate any code, or pseudocode, someone could provide.

The input will be a list of triples like so

[[x1, y1, z1], [x2, y2, z2], [x3, y3, z3],..., [xn, yn, zn]]

What I need is the mean and standard deviation/variance of the two dimensional normal distribution that most closely represents the data, so as to be able to manipulate it, and, later, recreate it.

example

For the sake of simplicity I will defer to using a one dimensional normal function. If I have the following two dimensional data points

[
    [-4, 0.0001],
    [-3, 0.0044],
    [-2, 0.054 ],
    [-1, 0.242 ],
    [0 , 0.3989],
    [1 , 0.242 ],
    [2 , 0.054 ],
    [3 , 0.0044],
    [4 , 0.0001]
]

I expect the script to output

mean = 0.0
standard deviation = 1.0
variance = 1.0

That way, if I want to, for example, change the standard deviation from sd = 1.0 to sd = 2.0, I can modify the curve, recreate it, sample the points -4...4, and rewrite the values to the data like so.

[
    [-4, 0.027 ],
    [-3, 0.0648],
    [-2, 0.121 ],
    [-1, 0.176 ],
    [0 , 0.1995],
    [1 , 0.176 ],
    [2 , 0.121 ],
    [3 , 0.0648],
    [4 , 0.027 ]
]

Now my question is: how do I do that with a list of three dimensional points which closely represent a two dimensional normal distribution?


I would prefer to do this in Python, or to call a shell script. However, I would not be against using a program like MatLab or Maple.

  • 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-28T01:38:03+00:00Added an answer on May 28, 2026 at 1:38 am

    According to the 1D example, we are given a sequence of values (xi, yi), where the xi values are vectors of dimension n (n = 1 or n = 2), and the yi values are scalars. We wish to find mean mu and covariance matrix sigma for a Gaussian function f of dimension n such that the f(xi) values are close to the yi values.

    To solve this problem we have to define what close means. We can choose for example to minimize the sum of the squares (yi - f(xi))^2. The resulting non-linear optimization problem in mu and sigma can be solved with an iterative method such as Levenberg–Marquardt.


    If MatLab is used perhaps see their Curve Fitting Guide, specifically the Nonlinear Curve Fitting section and the lsqnonlin and lsqcurvefit examples. If Python is used, you can find library bindings to Levenberg–Marquardt implementations in C/C++ or Fortran.

    Whatever approach is used, I recommend trying out the solver on the 1D example first.

    Another relevant resource is SciPy’s data fitting cookbook, which includes a section on fitting a 2D gaussian.

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

Sidebar

Related Questions

Am looking converter for xls to sql converter . Or Is There any script
Is there any way to have PHP automatically call a function, before a script
I am looking for a sentiment analysis script / soyurce code preferably in PHP.
I'm looking for exception handling mechanism in shell script. Is there any try,catch equivalent
I am looking for a python script that can dump ELF file (of type
im looking for any information about a builtin algorithm in opengl es to convert
I'm looking for any way that I can improve the selector performance of a
I am looking for any strategies people use when implementing server applications that service
I'm looking for any resources on hosting a WPF form within an existing MFC
I'm looking for any tools that can give you code churn metrics (graphs and

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.