[OT] economics and valuations

B

Bill Cunningham

I thought I might post this site to let those who care know my "next
project". I will be looking at harmonic and geometric means and fincial
analysis and economics. I am going to try to work out geometric and harmonic
means myself in C. If I have a problem will ask for help.

Thanks

Bill
 
B

Bill Cunningham

Bill Cunningham said:
I thought I might post this site to let those who care know my "next
project". I will be looking at harmonic and geometric means and fincial
analysis and economics. I am going to try to work out geometric and
harmonic means myself in C. If I have a problem will ask for help.

Thanks

Bill

Oops the webiste.
http://www.maxvalue.com/tipindex.htm
 
U

user923005

    I thought I might post this site to let those who care know my "next
project". I will be looking at harmonic and geometric means and fincial
analysis and economics. I am going to try to work out geometric and harmonic
means myself in C. If I have a problem  will ask for help.

Perhaps this can give you a leg up:

/* Steve Summit's C programming
*
* Section 3 :: exercise 2
*
* STATEMENT: Write a program to compute the average of the ten
numbers 1, 4,
* 9, ..., 81, 100, that is, the average of the squares of the
numbers from
* 1 to 10. (This will be a simple modification of Exercise 3 from
last
* week: instead of printing each square as it is computed, add it in
to a
* variable sum which keeps track of the sum of all the squares, and
then at
* the end, divide the sum variable by the number of numbers summed.)
*
*/

#include <stdio.h>
#include <math.h>
#include <assert.h>

double geometricMean(size_t count, double vector[])
{
double sum = vector[0];
size_t index;

if (count == 0)
return 0;
for (index = 1; index < count; index++)
sum *= vector[index];

return pow(sum, 1.0 / count);
}

/* Ref: http://mathworld.wolfram.com/PowerMean.html */
/* CANNOT be used on negative quantities! */
double generalizedMean(double power, size_t count, double
vector[])
{
size_t index;
double sum = 0;

if (count == 0)
return 0;
if (power == 0)
sum = geometricMean(count, vector);
else {
for (index = 0; index < count; index++) {
assert(vector[index] > 0);
sum += pow(vector[index], power);
}
sum /= count;
sum = pow(sum, 1.0 / power);
}
return sum;
}

double arithmeticMean(size_t count, double vector[])
{
double sum = 0;
size_t index;

if (count == 0)
return 0;
for (index = 0; index < count; index++)
sum += vector[index];

return sum / count;
}

double harmonicMean(size_t count, double vector[])
{
double sum = 0;
size_t index;

if (count == 0)
return 0;
for (index = 0; index < count; index++)
sum += 1.0 / vector[index];
sum /= count;
return 1.0 / sum;
}

double rmsMean(size_t count, double vector[])
{
double sum = 0;
size_t index;

if (count == 0)
return 0;
for (index = 0; index < count; index++)
sum += vector[index] * vector[index];

sum /= count;
return sqrt(sum);
}

int main()
{
int i;
double vector[10];

for (i = 1; i <= 10; ++i) {
vector[i - 1] = i * i;
}

printf("The Arithmetical average is: %.1f\n", generalizedMean
(1.0, 10, vector));
printf("Checking.....................: %.1f\n\n", arithmeticMean
(10, vector));
printf("The Harmonic average is: %.1f\n", generalizedMean
(-1.0, 10, vector));
printf("Checking.....................: %.1f\n\n", harmonicMean(10,
vector));
printf("The Geometric average is: %.1f\n", generalizedMean
(0.0, 10, vector));
printf("Checking.....................: %.1f\n\n", geometricMean
(10, vector));
printf("The RootMeanSquare average is: %.1f\n", generalizedMean
(2.0, 10, vector));
printf("Checking.....................: %.1f\n\n", rmsMean(10,
vector));

return 0;
}
 
B

Bill Cunningham

I thought I might post this site to let those who care know my "next
project". I will be looking at harmonic and geometric means and fincial
analysis and economics. I am going to try to work out geometric and
harmonic
means myself in C. If I have a problem will ask for help.

Perhaps this can give you a leg up:

[snip]

Oh great thanks.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top