LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i fit the Gaussian curve?

Hi everybody,
I want to align the left side of curve to the right side.
I want to get rid of the height on the left side and get a fitted gaussian curve.
The formula I use is correct.
I explained in the picture that I need to do it.
Please help me.

Kind regards.

Download All
0 Kudos
Message 1 of 10
(4,374 Views)

The output of the Gaussian Peak Fit VI will be symmetrical, but you might have to fiddle with the weights to get the fit you want. I notice that the y-axis is logarithmic, meaning that the fit will appear to 'care' more about the bits of the line that are higher up the axis. By varying the weights, or performing the fit on log(y) data, you can overcome this.

 

Alternatively, try fitting by hand. You can probably estimate the two parameters (mean and standard deviation) pretty well.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 2 of 10
(4,325 Views)

Use nonlinear curve fit with a model that consists of a gaussian and a polynomial background of sufficient order.

0 Kudos
Message 3 of 10
(4,318 Views)

Hi MaxJoseph and altenbach,

How can i do this. Its not clear for me. If you have time can you show me please.

0 Kudos
Message 4 of 10
(4,296 Views)

To fit by hand I make a spreadsheet in excel. I make a list of x values and then define a list of y values (y-fit)according to an equation of my choice. In this case you want the Gaussian function. The Wikipedia page has all the information you need to get the right function. Define two cells as mu and sigma. Then put a list of values (y-actual) and plot y-fit vs x and y-axtual vs x on the same plot. Fiddle with the values of mu and sigma until you get a reasonable fit.

 

Then you can take you rough fitted values as starting points for the Gaussian fit function. You should be comfortable with doing this, if not then you will need to look at some beginner level tutorials focussing on graphing.

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 5 of 10
(4,288 Views)

@AnnihilationSpectrum wrote:

How can i do this. Its not clear for me. If you have time can you show me please.


Glancing at your code for a few seconds, you first need to do a few simple LabVIEW beginner tutorials, because whatever code you have attached contains glaring race conditions, mostly due to the blatant overuse of local variables. None are needed. Even the sequence structure is not needed. For example, in your while loop, you write to and read from local variables of the same indicator in parallel and the outcome critically depends on the order of operations, but the order is not predictable. All you need is wires! If you want to see the current value, wire the indicator to it. No locals needed!

 

After that, have a look at my "Practical nonlinear fitting" page for some ideas.

 

Now about the data. It seems your data is a Gaussian if graphed on a logarithmic scale, so it is probably a different shape in linear space. Where does the data come from? What does it represent? What is the theory behind the shape?

 

0 Kudos
Message 6 of 10
(4,267 Views)

Hi altenbach,
Thank you for your reply.
Theory behind the shape is Positron Annihilation Spectroscopy. I work with a linear positron accelerator.
The data are taken from the accelerator. Now, I'm working offline.
The accelerator has its own radiation source, There is a radiation background from the other sources like soil, electronic devices etc. And this background creates an asymmetry between the left side and the right side of the spectrum curve.
The left side of peak is high because there is background radiation. I want to get rid of it and to see the left side and the right side of the Gaussian curve equal. The level that should be is the right side of the curve. Using these formulas, I tried to reduce the background of the left side.

Please help me to fix it. Nobody helps me.

Download All
0 Kudos
Message 7 of 10
(4,243 Views)

That background is 0.1%of the total amplitude and nearly on the order of the noise. Is the background really just a step or linear function or more complicated?

What is "n" in your formula?

The right and left side can never be equal, because the sign of their slope differs.

 

Here are the formulas you have attached. Why didn't you insert them in the post isntead of attaching them?

 

First formula:

 

first%20formula

 

Second Formula:

 

second%20formula

0 Kudos
Message 8 of 10
(4,234 Views)

These formulas are step function. So, thank you very much for your helps. I solved the problem. Now, its looking fine.

0 Kudos
Message 9 of 10
(4,218 Views)

A step function is certainly not the right tools here, but since the peak is orders of magnitude larger, the step is not noticeable there. I am sure there is a better theory on the exact shape of the background. Nature typically does not have steps like that. 😄

0 Kudos
Message 10 of 10
(4,211 Views)