Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Regresia exponentiala
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <math.h>
- #define NRMAX 10
- void regexp (int m, float x[NRMAX], float y[NRMAX], float *a, float *b);
- int main (void)
- {
- int i,m;
- float a,b;
- float X[NRMAX],Y[NRMAX];
- printf("\nRegresia exponentiala \n");
- printf("\nIntroduceti numarul experientelor:");
- scanf("%d",&m);
- printf("\nIntroduceti abscisele si ordonatele functiei:");
- for (i=0;i<m;i++)
- {
- printf("\nX[%d]=",i);
- scanf("%f",&X[i]);
- printf("Y[%d]=",i);
- scanf("%f",&Y[i]);
- }
- regexp(m,X,Y,&a,&b);
- printf("Rezultatul regresiei geometrice este: a=%f; b=%f",a,b);
- getch();
- return 1;
- }
- void regexp (int m, float x[NRMAX], float y[NRMAX], float *a, float *b)
- {
- float sx,sy,sxx,sxy;
- int i;
- sx=0; sy=0; sxx=0; sxy=0;
- for (i=0;i<m;i++)
- { sx=sx+(x[i]);
- sy=sy+log(y[i]);
- sxy=sxy+x[i]*log(y[i]);
- sxx=sxx+x[i]*x[i];
- }
- *a=exp( (sy*sxx-sx*sxy)/(m*sxx-sx*sx) );
- *b=exp( (m*sxy-sx*sy)/(m*sxx-sx*sx) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement