Histogram Background Subtraction

I have two histograms: one for counts across an energy range and one for the background counts across the same range. The histograms have the same bin characteristics. I would like to subtract the counts of the background histogram from the counts of the data histogram, without changing the bin characteristics. However, when I subtract them, the bin characteristics are affected. Additionally, is there a way to scale the counts in a histogram (like double the number of counts in each bin) without changing the bin characteristics. For example, if my histogram has a gaussian shape with a peak at x=250, and I do the following:

Variable i=0
Do
TempHistScale[i]=TempHistBack[i]*2
i+=1
While(i
Then the peak of the gaussian for TempHistScale will be at ~x=50 (why?). I looked for awhile on the forum and IGOR's manual, but I am very sorry if I missed it/ the solution is obvious. Thanks.
Sorry, I must have cut off some:

I have two histograms: one for counts across an energy range and one for the background counts across the same range. The histograms have the same bin characteristics. I would like to subtract the counts of the background histogram from the counts of the data histogram, without changing the bin characteristics. However, when I subtract them, the bin characteristics are affected. Additionally, is there a way to scale the counts in a histogram (like double the number of counts in each bin) without changing the bin characteristics. For example, if my histogram has a gaussian shape with a peak at x=250, and I do the following:

Variable i=0
Do
TempHistScale[i]=TempHistBack[i]*2
i+=1
While(i (less than) numpnts(TempHistBack))

Then the peak of the gaussian for TempHistScale will be at ~x=50 (why?). I looked for awhile on the forum and IGOR's manual, but I am very sorry if I missed it/ the solution is obvious. Thanks.
You don't tell us about the details of TempHistScale and TempHistBack.

You are better off doing this with a wave assignment:

TempHistScale = 2*TempHistBack

which implies a loop over all points of TempHistScale. If the two histograms cover different X ranges, you will need to do some gymnastics to get the arithmetic to do the Right Thing. The easiest way to subtract two waves that don't have equal X ranges is to use the Wave Arithmetic package. See the demo at File->Example Experiments->Analysis->Wave Arithmetic Panel Demo.


To read about wave assignments, copy this command, paste it into Igor's command line and press enter:

DisplayHelpTopic "Waveform Arithmetic and Assignment"


And to post code that includes things like greater than signs, see this: http://www.igorexchange.com/filter/tips
and read about the igor tag.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Ah thats it. I had changed the offset and the scale when creating the first histogram, and copying it did in fact revert the scale back to 0 and 1 respectively for the copy. I was able to get it to work with SetScale. Thank you very much!
You might want to make the copy using Duplicate. It copies X scaling, data, etc. I often use Duplicate even when I'm not interested in the copied data, just to make sure all aspects of the new wave match the old one.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com