Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
.
//g++ 7.4.0 #include <iostream> #include <fstream> #include <cmath> #include <string> #include <vector> #include <random> using namespace std; int main() { vector<double>v={42.5, 36.7 , 36.15, 36.65, 38.3 , 39.7 , 41.3 , 43.3 , 44.9 , 46.85, 48.8 , 50.6 , 52.5 , 54.45, 56.25, 58.3 , 60.2 , 62.15, 64.2 , 66.15, 68.1 , 70 , 71.95}; vector<double>w(v.size()); for(int i=0;i<v.size();i++) { w[i]=v[i]-8; cout<<w[i]; cout<<endl; } return 0; } #include <iostream> #include <fstream> #include <cmath> #include <string> #include <vector> #include <random> using namespace std; double ChiQuadro(vector<double> Yi,vector<double> ErrY, vector<double> Xi,double a,double b); int main() { char Ans; cout << "Chi Quadro?" <<endl; cin >> Ans; vector<double> Dati; vector<double> Errori; ifstream yin("Y.txt"); ifstream ein("Errori.txt"); double sum=0; double c1,c2; while(yin >> c1) { //c1=2*M_PI/c1; Dati.push_back(c1); sum+=c1; } while(ein >> c2) { Errori.push_back(c2); } sum=sum/Dati.size(); double dev=0; for(int i=0; i<Dati.size(); i++){ dev+=pow(sum-Dati[i],2); } dev=sqrt(dev/(Dati.size()-1)); cout << " media : " << sum << endl; cout << " dev : " << dev << endl; double unosusig2=0; double medpes=0; double ErrEmed=0; for (int i=0; i<Dati.size(); i++){ //Media pesata medpes+=Dati[i]/pow(Errori[i],2); unosusig2+=1/pow(Errori[i],2); } medpes=medpes/unosusig2; ErrEmed=sqrt(1/unosusig2); //cout << " media pesata : " << medpes << endl; //cout << " errore media pesata : " << ErrEmed << endl; cout << "$ "<< medpes <<"\\pm " << ErrEmed << "$ &" <<endl; if(Ans=='y'){ ifstream xin("X.txt"); double a,b; cout<< "inserire a e b"; cin >> a; cin >> b; vector<double> X; double j; while (xin >> j){ X.push_back(j); } cout << ChiQuadro(Dati, Errori,X,a,b)<< endl; cout << "Gradi di libertà : "<< Dati.size()-2<< endl; } return 0; } double ChiQuadro(vector<double> Yi,vector<double> ErrY, vector<double> Xi,double a,double b){ double Yattesa,Chi; for(int i=0; i<Yi.size(); i++){ //Yattesa=a*exp(Xi[i]); //inserire funzione interpolante Yattesa=a+b*Xi[i]; Chi+=pow((Yi[i]-Yattesa)/ErrY[i],2); } return Chi; }
run
|
edit
|
history
|
help
0
Problem: binary
Operator Overload
mua
OperatorOverload
Kishan_template
cache_node.cc
binary
break.cpp
1163. Last Substring in Lexicographical Order
Template arguments pack