- #1

- 177

- 1

You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter mjordan2nd
- Start date

- #1

- 177

- 1

- #2

Mark44

Mentor

- 34,825

- 6,568

- #3

- 83

- 0

- #4

- 177

- 1

- #5

- 177

- 1

Here's the real problem:

I have a situation where a laser hits a linear polarizer, and a motorized analyzer. I assume the angle between the polarizer and the analyzer transmission axis is linear in time: [tex] \theta = \omega t + k[/tex]. I collect data for this as time progresses through a computer, and I want to fit it to Malus' law. Here's the code for gnuplot:

I will attempt to attach run2.dat.

For some reason, I cannot seem to get a good fit. Any help would be appreciated.

I have a situation where a laser hits a linear polarizer, and a motorized analyzer. I assume the angle between the polarizer and the analyzer transmission axis is linear in time: [tex] \theta = \omega t + k[/tex]. I collect data for this as time progresses through a computer, and I want to fit it to Malus' law. Here's the code for gnuplot:

Code:

```
set title 'Irradiance vs time'
set xlabel "Seconds"
set ylabel "Volts"
w = 0.314535
I = 0.636548
k = 0-.62469
FIT_LIMIT = 1e-99
l(x) = I * cos(w * x + k)**2
fit l(x) 'run2.dat' via w, I, k
plot l(x), 'run2.dat'
```

I will attempt to attach run2.dat.

For some reason, I cannot seem to get a good fit. Any help would be appreciated.

- #6

Mark44

Mentor

- 34,825

- 6,568

I don't see anything drastically wrong with this graph, other than it is very crude. The graphing program is probably evaluating the function at too few points (because of the large x interval), so it might not be showing what you think it should.It looks like this, which doesn't seem to be periodic over pi at all. When I do it on gnuplot I get the same result. On my calculator it looks like a wave-packer going through approximately two waves. So I'm trying to figure out why this is happening.

- #7

Mark44

Mentor

- 34,825

- 6,568

Can you be more specific about what you mean when you say you can't get a good fit?Here's the real problem:

I have a situation where a laser hits a linear polarizer, and a motorized analyzer. I assume the angle between the polarizer and the analyzer transmission axis is linear in time: [tex] \theta = \omega t + k[/tex]. I collect data for this as time progresses through a computer, and I want to fit it to Malus' law. Here's the code for gnuplot:

Code:`set title 'Irradiance vs time' set xlabel "Seconds" set ylabel "Volts" w = 0.314535 I = 0.636548 k = 0-.62469 FIT_LIMIT = 1e-99 l(x) = I * cos(w * x + k)**2 fit l(x) 'run2.dat' via w, I, k plot l(x), 'run2.dat'`

I will attempt to attach run2.dat.

For some reason, I cannot seem to get a good fit. Any help would be appreciated.

- #8

- 177

- 1

I can show you. Based on the data and the code I have provided so far, gnuplot will do 5 iterations and no more. I have attached the plot for my data and my "fitted" function. It seems visually apparent that the "fit" is not "good", unless I am misinterpreting something horribly.

In case it is helpful, the output gnuplot gives me is:

In case it is helpful, the output gnuplot gives me is:

Code:

```
Max. number of data points scaled up to: 3072
Iteration 0
WSSR : 891.708 delta(WSSR)/WSSR : 0
delta(WSSR) : 0 limit for stopping : 1e-099
lambda : 36.5893
initial set of free parameter values
w = 0.314535
I = 0.636548
k = -0.62469
/
Iteration 1
WSSR : 852.627 delta(WSSR)/WSSR : -0.0458357
delta(WSSR) : -39.0808 limit for stopping : 1e-099
lambda : 3.65893
resultant parameter values
w = 0.314876
I = 0.739896
k = -0.637262
/
Iteration 2
WSSR : 829.851 delta(WSSR)/WSSR : -0.0274469
delta(WSSR) : -22.7768 limit for stopping : 1e-099
lambda : 0.365893
resultant parameter values
w = 0.315894
I = 0.889393
k = -0.764851
/
Iteration 3
WSSR : 829.244 delta(WSSR)/WSSR : -0.000731871
delta(WSSR) : -0.606899 limit for stopping : 1e-099
lambda : 0.0365893
resultant parameter values
w = 0.316624
I = 0.893281
k = -0.858558
***********/
Iteration 4
WSSR : 829.244 delta(WSSR)/WSSR : -1.78226e-015
delta(WSSR) : -1.47793e-012 limit for stopping : 1e-099
lambda : 3.65893e+008
resultant parameter values
w = 0.316624
I = 0.893281
k = -0.858558
************
After 5 iterations the fit converged.
final sum of squares of residuals : 829.244
rel. change during last iteration : 0
degrees of freedom (FIT_NDF) : 2438
rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 0.583209
variance of residuals (reduced chisquare) = WSSR/ndf : 0.340133
Final set of parameters Asymptotic Standard Error
======================= ==========================
w = 0.316624 +/- 0.0002631 (0.08311%)
I = 0.893281 +/- 0.01918 (2.147%)
k = -0.858558 +/- 0.03712 (4.323%)
correlation matrix of the fit parameters:
w I k
w 1.000
I 0.066 1.000
k -0.865 -0.056 1.000
gnuplot>
```

- #9

- 177

- 1

I don't see anything drastically wrong with this graph, other than it is very crude. The graphing program is probably evaluating the function at too few points (because of the large x interval), so it might not be showing what you think it should.

I see. So is it safe to say the software is not designed to handle such a large domain? Is this true for most computational programs in general for trig functions? My calculator gives me nonsense results as well. Even more interestingly, plotting cos(x) produces what visually appears to be nonsense on both the link above and my TI-89. I haven't tried it yet for gnuplot.

If this is a problem of not enough x values being evaluated, do you know if there is a way I can change this in gnuplot? It would be nice to be able to get a fit for my data.

Share: