Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Weighted Index
//g++ 7.4.0 //Weighted index: finding weighted indices for different methods //created by Rezaul Hoque on December 30,2020 //contact at jewelmrh@yahoo.com #include <iostream> #include <cmath> using namespace std; int main () { int n = 4; float sum1 =0,sum2=0, sum3=0, sum4=0,sum5=0, sum6=0,prod; float L,P,B,F,ME; float a0[n] ={2,5,4,2}; float a1[n] = {4,6,5,2}; float b0[n] = {8,10,14,19}; float b1[n] = {6,5,10,13}; for(int i=0;i<n; i++) { sum1 += a1[i]*b0[i]; sum2 += a0[i]*b0[i]; sum3 += a1[i]*b1[i]; sum4 += a0[i]*b1[i]; sum5 += (b0[i]+b1[i])*a1[i]; sum6 += (b0[i]+b1[i])*a0[i]; } L = sum1/sum2 *100; P = sum3/sum4 *100; B = (sum1/sum2 +sum3/sum4)/2 * 100; prod= (sum1/sum2) *(sum3/sum4); F= sqrt(prod)*100; ME = sum5/sum6 * 100; cout<<" Laspeyres Method:\t"<<L<<endl; cout<<" Paasche Method:\t"<<P<<endl; cout<<" Bowley's Method:\t"<<B<<endl; cout<<"Fisher's Ideal Method:\t"<<F<<endl; cout<<" Marshall-Edgeworth Method:\t"<<ME<<endl; return 0; }
run
|
edit
|
history
|
help
0
VirtualResto
queue
FunTemp
<string> Indirect include of <errno.h> with gcc
Stream8
Boost phoenix. e.g 3 phoenix: functor
Reminder
References Pt 1 C++
Factorial Inv wip
Replace substring poor