MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Problem to be solved (Product of Normal Distributions)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14166] Re: Problem to be solved (Product of Normal Distributions)
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Wed, 30 Sep 1998 02:04:15 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

>Imagine I have something like ax^2+bx+c. Now I want to know how to make
>Mathematica return me something in the form (x+d)^2, where d depends on
>a, b and c.
>
>This is the simple form. In reality I am trying to determine the sigma
>and mu of a product of the form
>
>        f_i=1/(sqrt(2 pi) sigma_i) Exp( -(x-mu_i)^2/(2 sigma_i^2)  )
>
>So I want to know what is the sigma and mu of f_1 times f_2.
>
>Now that you know it, I can also add that I tried Collect in every way,
>and some substituion rules.

Attached is one (semi-automatic) approach using pattern-matching and
taking advantage of Mathematica's typesetting.

Cheers,
	Paul

"NormalDistribution.nb"

(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the
notebook starts with the line of stars above.

To get the notebook into a Mathematica-compatible application, do one of
the following:

* Save the data starting with the line of stars above into a file
  with a name ending in .nb, then open the file inside the application;

* Copy the data starting with the line of stars above to the
  clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be sent
directly in email or through ftp in text mode.  Newlines can be CR, LF
or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.

For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
  web: http://www.wolfram.com
  email: info at wolfram.com
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from Wolfram
Research.
***********************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[      5481,        158]*)
(*NotebookOutlinePosition[      6319,        185]*) (* 
CellTagsIndexPosition[      6275,        181]*) (*WindowFrame->Normal*)


Notebook[{
Cell[TextData[{
  "The product of ",
  Cell[BoxData[
      \(TraditionalForm\`n\)]],
  " (normalized) normal distributions," }], "Text"],

Cell[BoxData[
    \(TraditionalForm\`\(\
    \(1\/\(\ at \(2\ \[Pi]\)\ \[Sigma]\_i\)\)
      \[ExponentialE]\^\(-
          \(\((x - \[Mu]\_i)\)\^2\/\(2\ \[Sigma]\_i\%2\)\)\)\)\)],
  "DisplayFormula"],

Cell["is", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\[ExponentialE]\^\(-
          \(\[Sum]\+\(i = 1\)\%n
              \((x - \[Mu]\_i)\)\^2\/\(2\ \[Sigma]\_i\%2\)\)\)\/\(\((2\
\[Pi])
            \)\^\(n/2\)\ \(\[Product]\+\(i = 1\)\%n \[Sigma]\_i\)\)\)],
  "DisplayFormula"],

Cell["The (negative) argument of the exponential function is", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\[Sum]\+\(i = 1\)\%n\((x - \[Mu]\_i)\)\^2\/\(2\ \[Sigma]\_i\%2\)
      \[Equal] \(x\^2\/2\) \(\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2\) -
        x \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\/\[Sigma]\_i\%2\) +
        \(1\/2\) \(\[Sum]\+\(i = 1\)\%n
\[Mu]\_i\%2\/\[Sigma]\_i\%2\)\)],
  "DisplayFormula"],

Cell["Using pattern-matching, we complete the square", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm
    \`\(x\^2\/2\) \(\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2\) -
        x \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\/\[Sigma]\_i\%2\) +
        \(1\/2\) \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\%2\/\[Sigma]\_i\%2\) /.
      a_\ x\^2 + b_\ x + c_ \[Rule]
        a\ \((x + b\/\(2  a\))\)\^2 - b\^2\/\(4  a\) + c\)], "Input"],

Cell[BoxData[
    \(TraditionalForm
    \`\(-\(\((\[Sum]\+\(i = 1\)\%n \[Mu]\_i\/\[Sigma]\_i\%2)\)\^2\/\(2\
              \(\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2\)\)\)\) +
      1\/2\ \((\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2)\)\
        \((x - \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\/\[Sigma]\_i\%2
                      \)\/\(\[Sum]\+\(i = 1\)\%n
1\/\[Sigma]\_i\%2\))\)\^2 +
      1\/2\ \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\%2\/\[Sigma]\_i\%2\)\)],
"Output"] }, Open  ]],

Cell["Hence the general product in simplest terms reads", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(\[ExponentialE]\^\(\((\[Sum]\+\(i = 1\)\%n
\[Mu]\_i\/\[Sigma]\_i\%2)
                    \)\^2\/\(2\
                  \(\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2\)\) -
              1\/2\ \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\%2\/\[Sigma]\_i\%2
                      \)\)\/\(\((2\ \[Pi])\)\^\(n/2\)\
            \(\[Product]\+\(i = 1\)\%n \[Sigma]\_i\)\)\)
      \[ExponentialE]\^\(\(-\(1\/2\)\)\
          \((\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2)\)\
          \((x - \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\/\[Sigma]\_i\%2
                        \)\/\(\[Sum]\+\(i = 1\)\%n
1\/\[Sigma]\_i\%2\))\)\^2
            \)\)], "Input"],

Cell[TextData[{
  "Comparing the last exponential term with ",
  Cell[BoxData[
      \(TraditionalForm
      \`\[ExponentialE]\^\(-\(\((x - \[Mu])\)\^2\/\(2\
\[Sigma]\^2\)\)\)\)]],
  " we see that"
}], "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(\[Sum]\+\(i = 1\)\%n 1\/\[Sigma]\_i\%2 \[Rule] 1\/\[Sigma]\^2,
\)\)],
  "DisplayFormula"],

Cell["and", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\/\[Sigma]\_i\%2 \[Rule]
      \[Mu]\/\[Sigma]\^2, \)\)], "DisplayFormula"],

Cell["and hence the product can be written as", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(\[ExponentialE]\^\(\(1\/2\) \[Mu]\^2\/\[Sigma]\^2 -
              1\/2\ \(\[Sum]\+\(i = 1\)\%n \[Mu]\_i\%2\/\[Sigma]\_i\%2
                      \)\)\/\(\((2\ \[Pi])\)\^\(n/2\)\
            \(\[Product]\+\(i = 1\)\%n \[Sigma]\_i\)\)\)
      \(\[ExponentialE]\^\(-
            \(\((x - \[Mu])\)\^2\/\(2\
\[Sigma]\^2\)\)\)\[CenterDot]\)\)],
  "DisplayFormula"],

Cell["\<\
Note that, in general, the product is no longer correctly \ normalized.\
\>", "Text"]
},
FrontEndVersion->"Macintosh 3.0",
ScreenRectangle->{{0, 800}, {0, 580}}, WindowSize->{795, 532},
WindowMargins->{{Automatic, 1}, {Automatic, 1}},
MacintoshSystemPageSetup->"\<\
00<0001804P000000c at 2@?oeooH3?`990dL5N`?P0080001804P000000`d26P01
0000I00000400 at 410?l00BL?00400@0000000000000006P801T1T0000000h000
00000000007oo`00003oo`000o800000\>"
]


(***********************************************************************
Cached data follows.  If you edit this Notebook file directly, not
using Mathematica, you must remove the line containing CacheID at the
top of the file.  The cache data will then be recreated when you save
this file from within Mathematica.
***********************************************************************)

(*CellTagsOutline
CellTagsIndex->{}
*)

(*CellTagsIndex
CellTagsIndex->{}
*)

(*NotebookFileOutline
Notebook[{
Cell[1709, 49, 136, 5, 30, "Text"],
Cell[1848, 56, 200, 5, 56, "DisplayFormula"], Cell[2051, 63, 18, 0, 30,
"Text"],
Cell[2072, 65, 267, 6, 63, "DisplayFormula"], Cell[2342, 73, 70, 0, 30,
"Text"],
Cell[2415, 75, 338, 6, 56, "DisplayFormula"], Cell[2756, 83, 62, 0, 30,
"Text"],

Cell[CellGroupData[{
Cell[2843, 87, 343, 6, 60, "Input"], Cell[3189, 95, 453, 7, 81,
"Output"] }, Open  ]],
Cell[3657, 105, 65, 0, 30, "Text"],
Cell[3725, 107, 664, 12, 95, "Input"], Cell[4392, 121, 209, 6, 44,
"Text"], Cell[4604, 129, 134, 3, 56, "DisplayFormula"], Cell[4741, 134,
19, 0, 30, "Text"],
Cell[4763, 136, 149, 3, 56, "DisplayFormula"], Cell[4915, 141, 55, 0,
30, "Text"],
Cell[4973, 143, 406, 8, 64, "DisplayFormula"], Cell[5382, 153, 95, 3,
30, "Text"]
}
]
*)



(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)



  • Prev by Date: Free Rubiks cube package
  • Next by Date: MRI analysis
  • Previous by thread: Free Rubiks cube package
  • Next by thread: MRI analysis