[Date Index]
[Thread Index]
[Author Index]
Re: Little(?) problem: What is the formula ???
*To*: mathgroup at smc.vnet.net
*Subject*: [mg21938] Re: [mg21911] Little(?) problem: What is the formula ???
*From*: Hartmut Wolf <hwolf at debis.com>
*Date*: Sat, 5 Feb 2000 00:49:14 -0500 (EST)
*Organization*: debis Systemhaus
*References*: <200002040754.CAA28512@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Nijntje ? schrieb:
>
> Hello All !
>
> I have two "series" of data :
> The first serie are "normal values"
> The seccond serie represents a percentage(Value) of an amount(Nominator)
>
> Serie 1)
> Value Nominator
> 100 1
> 150 1
> 125 1
>
> Serie 2)
> Value Nominator
> 10 100
> 12 200
> 15 300
>
> The Problem:
> --------------------------------------------------------------------------
> I want to find a GENERAL formula to calculate the SUM of these series,
> So a formula which gives the following results
>
> Serie 1) 365
> Serie 2) 13,1
>
> Explanation results:
> Serie 1) 100+150+125 = 375
>
> serie 2) 10% of 100 = 10
> 12% of 200 = 24
> 15% of 300 = 45
> So total amount = 600 and the fraction=79 so that is 13.1%
>
> What is the general formula (using value and nominator) ?????????
>
Suppose your data are written in Mathematica as
In[1]:= serie1 = {{100, 1}, {150, 1}, {125, 1}};
serie2 = {{10., 100}, {12., 200}, {15., 300}};
You may define a function to calculate the total sum of the countable
things, and with it together the percentage (or any other yet for the
consideration constant and same fraction) of things having a certain
property. This means calculate the weighted average of the fractions and
the sum, e.g. with that procedure
In[3]:=
was[data_] := Module[{s1, s2, ss},
{s1, s2} = Transpose[data]; ss = Plus @@ s2;
{s1.s2/ss, ss}]
For series 2 you indeed get the new percentage (or fraction) and the sum
of all things considered:
In[4]:= was[serie2]
Out[4]= {13.1667, 600}
That is what you supposed to get. But for series 1 you do get
In[5]:= was[serie1]
Out[5]= {125, 3}
not quite what you intended. What is wrong?
I think, all what you did is not to write down both series consistently.
Look in series 2, you have your countables at the right, your fractional
parts at the left (the same as the result is delivered). Yet in series 1
the countables are written to the left. So all you need is to write the
elements of series 1 in reversed order!
In[9]:= serie1a = Reverse /@ serie1
Out[9]= {{1, 100}, {1, 150}, {1, 125}}
In[10]:= was[serie1a]
Out[10]= {1, 375}
I hope to have helped somewhat,
Hartmut
Prev by Date:
**Re: Check[] *and* Off[]**
Next by Date:
**Re: Little(?) problem: What is the formula ???**
Previous by thread:
**Little(?) problem: What is the formula ???**
Next by thread:
**Re: Little(?) problem: What is the formula ???**
| |