Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
probability distribution function and isosurface

Subject: probability distribution function and isosurface

From: Mani Mani

Date: 25 Aug, 2010 22:09:05

Message: 1 of 5

I have an array containing [x, y, z] coordinates for different 200 molecules stored in a data file.
I want the 3D probability density function of the coordinates and then I have to calculate ( visualize) the isosurface for different iso value.

I am not able to generate the 3D pdf.
I tried this:

>>a=load('file.dat');
>>y=pdf('Nornal', a);
>>plot(y,a);

But I was not right.
Can anyobdy help me with this ?

Thanks
Mani

Subject: probability distribution function and isosurface

From: Roger Stafford

Date: 26 Aug, 2010 03:47:05

Message: 2 of 5

"Mani Mani" <mousumimani@yahoo.co.in> wrote in message <i544a1$rj9$1@fred.mathworks.com>...
> I have an array containing [x, y, z] coordinates for different 200 molecules stored in a data file.
> I want the 3D probability density function of the coordinates and then I have to calculate ( visualize) the isosurface for different iso value.
>
> I am not able to generate the 3D pdf.
> I tried this:
>
> >>a=load('file.dat');
> >>y=pdf('Nornal', a);
> >>plot(y,a);
>
> But I was not right.
> Can anyobdy help me with this ?
>
> Thanks
> Mani
- - - - - - - - - - -
  Two hundred is not a lot of points to work with for three dimensions. However, you could try doing something like this. For any molecule at the point (x0,y0,z0) you could consider that it has been smeared into a three-dimensional Gaussian distribution with x0,y0,z0 as mean and some appropriate sigma, hopefully large enough for the Gaussians to overlap appreciably for the various molecules. Real life molecules do after all have a definite extent in space. By adding all the separate pdf's for the molecules and dividing by their total number you would have a kind of "smoothed" probability density. The greater sigma is, the more smoothing occurs, but the less sensitivity you have to local variation.

  Let X, Y, and Z be vectors of the x, y, and z coordinates of the positions of all the molecules and let sigma be a value you have carefully selected. Then prepare a function, either anonymous or a subfunction, that does this:

function p = moleculepdf(x,y,z)
p = 1/(length(X)*sigma^3*(2*pi)^(3/2)) * ...
    sum(exp(-((x-X).^2+(y-Y).^2+(z-Z).^2)/(2*sigma^2)));
return

This can constitute your probability density function, p(x,y,z). It has the property that its total triple integral over all 3D space is one. You may prefer to access the statistics toolbox to call on mvnpdf to make this computation simpler for yourself.

  Of course one drawback to this scheme is that such a density function in theory extends infinitely far in all directions. However if sigma is not selected too large, the density should die off reasonably quickly outside the bounds of the molecular "object", whatever it is. By the way, if I am not too inquisitive, what is this two-hundred molecule object?

Roger Stafford

Subject: probability distribution function and isosurface

From: Roger Stafford

Date: 26 Aug, 2010 04:08:05

Message: 3 of 5

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i54o3p$4m6$1@fred.mathworks.com>...
> .......
> function p = moleculepdf(x,y,z)
> p = 1/(length(X)*sigma^3*(2*pi)^(3/2)) * ...
> sum(exp(-((x-X).^2+(y-Y).^2+(z-Z).^2)/(2*sigma^2)));
> return
> .......
- - - - - - - -
  I could just as well have said:

p = 1/(sigma^3*(2*pi)^(3/2)) * ...
    mean(exp(-((x-X).^2+(y-Y).^2+(z-Z).^2)/(2*sigma^2)));

Roger Stafford

Subject: probability distribution function and isosurface

From: Mani

Date: 26 Aug, 2010 14:10:21

Message: 4 of 5

Thank you very much for the reply.
I will try this and come back if I need further assistance.

I am simulating a liquid by molecular dynamic simulation and my representative system contains 200 molecules ( two different types, 100 each). The system has periodic boundary condition in all direction so this repeats in 3D and behaves like a bulk liquid.
So I need to work with these 200 molecules but, since this is dynamic system the time steps varies (500000 steps) and so does the coordinates at different time point.

I am interested to see the distribution of one type of molecule vs. the other at a randomly chosen time step.

Similar plots as in the Fig 4 & 5 of this paper:
http://pubs.acs.org/doi/full/10.1021/jp0364699
 is what I want to get finally.

Thank you very much
Mani


"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i54o3p$4m6$1@fred.mathworks.com>...
> "Mani Mani" <mousumimani@yahoo.co.in> wrote in message <i544a1$rj9$1@fred.mathworks.com>...
> > I have an array containing [x, y, z] coordinates for different 200 molecules stored in a data file.
> > I want the 3D probability density function of the coordinates and then I have to calculate ( visualize) the isosurface for different iso value.
> >
> > I am not able to generate the 3D pdf.
> > I tried this:
> >
> > >>a=load('file.dat');
> > >>y=pdf('Nornal', a);
> > >>plot(y,a);
> >
> > But I was not right.
> > Can anyobdy help me with this ?
> >
> > Thanks
> > Mani
> - - - - - - - - - - -
> Two hundred is not a lot of points to work with for three dimensions. However, you could try doing something like this. For any molecule at the point (x0,y0,z0) you could consider that it has been smeared into a three-dimensional Gaussian distribution with x0,y0,z0 as mean and some appropriate sigma, hopefully large enough for the Gaussians to overlap appreciably for the various molecules. Real life molecules do after all have a definite extent in space. By adding all the separate pdf's for the molecules and dividing by their total number you would have a kind of "smoothed" probability density. The greater sigma is, the more smoothing occurs, but the less sensitivity you have to local variation.
>
> Let X, Y, and Z be vectors of the x, y, and z coordinates of the positions of all the molecules and let sigma be a value you have carefully selected. Then prepare a function, either anonymous or a subfunction, that does this:
>
> function p = moleculepdf(x,y,z)
> p = 1/(length(X)*sigma^3*(2*pi)^(3/2)) * ...
> sum(exp(-((x-X).^2+(y-Y).^2+(z-Z).^2)/(2*sigma^2)));
> return
>
> This can constitute your probability density function, p(x,y,z). It has the property that its total triple integral over all 3D space is one. You may prefer to access the statistics toolbox to call on mvnpdf to make this computation simpler for yourself.
>
> Of course one drawback to this scheme is that such a density function in theory extends infinitely far in all directions. However if sigma is not selected too large, the density should die off reasonably quickly outside the bounds of the molecular "object", whatever it is. By the way, if I am not too inquisitive, what is this two-hundred molecule object?
>
> Roger Stafford

Subject: probability distribution function and isosurface

From: Mani

Date: 2 Sep, 2010 03:23:04

Message: 5 of 5

Hi,
I tried this to calculate pdf and isosurface using the suggestion but did not get it right.
I did this :

>> m=load('coms4t0mol1m.out');
>> [x, y, z]=meshgrid(m);
>> sigma=9;
>> mu=16;
>> p = 1/(length(m)*sigma^3*(2*pi)^(3/2)) * ...
sum(exp(-((x-mu).^2+(y-mu).^2+(z-mu).^2)/(2*sigma^2)));
>> fv=isosurface(x,y,z,p,.04);
??? Error using ==> isosurface at 74
V must be size 2x2x2 or greater.

The output that I get for p has dimension [1 300 300] so giving error.
I have calculated sigma and mu using excel, so put them in the equation.

I am new to MATLAB, and not able to get it right.
Would very much appreciate any help .

Thanks
Mani

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i54o3p$4m6$1@fred.mathworks.com>...
> "Mani Mani" <mousumimani@yahoo.co.in> wrote in message <i544a1$rj9$1@fred.mathworks.com>...
> > I have an array containing [x, y, z] coordinates for different 200 molecules stored in a data file.
> > I want the 3D probability density function of the coordinates and then I have to calculate ( visualize) the isosurface for different iso value.
> >
> > I am not able to generate the 3D pdf.
> > I tried this:
> >
> > >>a=load('file.dat');
> > >>y=pdf('Nornal', a);
> > >>plot(y,a);
> >
> > But I was not right.
> > Can anyobdy help me with this ?
> >
> > Thanks
> > Mani
> - - - - - - - - - - -
> Two hundred is not a lot of points to work with for three dimensions. However, you could try doing something like this. For any molecule at the point (x0,y0,z0) you could consider that it has been smeared into a three-dimensional Gaussian distribution with x0,y0,z0 as mean and some appropriate sigma, hopefully large enough for the Gaussians to overlap appreciably for the various molecules. Real life molecules do after all have a definite extent in space. By adding all the separate pdf's for the molecules and dividing by their total number you would have a kind of "smoothed" probability density. The greater sigma is, the more smoothing occurs, but the less sensitivity you have to local variation.
>
> Let X, Y, and Z be vectors of the x, y, and z coordinates of the positions of all the molecules and let sigma be a value you have carefully selected. Then prepare a function, either anonymous or a subfunction, that does this:
>
> function p = moleculepdf(x,y,z)
> p = 1/(length(X)*sigma^3*(2*pi)^(3/2)) * ...
> sum(exp(-((x-X).^2+(y-Y).^2+(z-Z).^2)/(2*sigma^2)));
> return
>
> This can constitute your probability density function, p(x,y,z). It has the property that its total triple integral over all 3D space is one. You may prefer to access the statistics toolbox to call on mvnpdf to make this computation simpler for yourself.
>
> Of course one drawback to this scheme is that such a density function in theory extends infinitely far in all directions. However if sigma is not selected too large, the density should die off reasonably quickly outside the bounds of the molecular "object", whatever it is. By the way, if I am not too inquisitive, what is this two-hundred molecule object?
>
> Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us