Subject | Re: Standard Deviation calculation using select query ? |
---|---|
Author | Ali Gökçen |
Post date | 2005-07-13T07:17:08Z |
Hey Mario,
why are you so pessimist? what is to be a programmer?
to be a drag-dropper? or visual screen graphic designer?
if writing a STDDEV function using a procedure very difficult for
you, then how may you write more complex programs?
what is STDDEViation?
n=total=0
sampleavg = AVG(myfiled) -- use coalasce if there is null values
for
select samplevalue from mytable into :myvalue
do
begin
n= n +1
total = total + (myvalue - sampleavg)*(myvalue - sampleavg);
end
stddev = sqrrootfunctionofUDF(total / (n-1))
if there is no sqrroot function in UDF, (i never need,
so i dont now if exists) you can write one yourself using newton
rapson method for example...
Regards.
Ali
--- In firebird-support@yahoogroups.com, "mario1fb" <mario1fb@y...>
wrote:
why are you so pessimist? what is to be a programmer?
to be a drag-dropper? or visual screen graphic designer?
if writing a STDDEV function using a procedure very difficult for
you, then how may you write more complex programs?
what is STDDEViation?
n=total=0
sampleavg = AVG(myfiled) -- use coalasce if there is null values
for
select samplevalue from mytable into :myvalue
do
begin
n= n +1
total = total + (myvalue - sampleavg)*(myvalue - sampleavg);
end
stddev = sqrrootfunctionofUDF(total / (n-1))
if there is no sqrroot function in UDF, (i never need,
so i dont now if exists) you can write one yourself using newton
rapson method for example...
Regards.
Ali
--- In firebird-support@yahoogroups.com, "mario1fb" <mario1fb@y...>
wrote:
> Thank you Philip for clarification. Most appreciated. At least Iknow
> now that STDDEV cannot be calculated using the Interbase SQL query.single
>
> BTW, 'in the old DOS days' this task could be done with just a
> line of code, e.g. in FoxPro database:procedure
> CALC CNT(), AVG(INDEX), STD(INDEX) TO aCNT, aAVG, aSTD
>
> and the result was calculated in a split of a second, no indexes
> required ...
> It appears that I will now have to write the whole complex
> in Delphi to extract the data from the table, place them in thememory
> array, and finally use the Delphi built in functions to calculatethe
> STDDEV, in order to achieve the same result.already ?...
>
> Unless, as Philip suggested, someone has done this better
> Any suggestions would be most welcome.()
>
> Regards,
> Mario
>
>
> --- In firebird-support@yahoogroups.com, "unordained"
> <unordained_00@c...> wrote:
> > Since nobody else is replying to this ...
> >
> > a) No, it's not an available aggregate function, nor is the MEAN
> you would need in order torows of
> > calculate the STDDEV manually.
> >
> > b) No, you can't add it as a user-defined-function (UDF) because
> Interbase and Firebird don't
> > expose an API by which your own functions could get multiple
> data. (I learned this when Iaggregate.)
> > asked about a product-aggregate instead of an additive-
> >want
> > So if it's not built-in, and you can't add it as a UDF, then that
> pretty much leaves you writing a
> > stored procedure (SP). I'm terrible at writing SP's, so you'll
> to get help from someone else.google
> > It's possible someone already has one written. A very quick
> search isn't turning one up.using
> >
> > -Philip
> >
> > ---------- Original Message -----------
> > From: "mario1fb" <mario1fb@y...>
> >
> > > Interbase alows for quick calculation of Sum, Average, etc.
> > > simple select statement:
> > > e.g.
> > > select AVG(INDEX), SUM(INDEX) from DATATABLE
> > >
> > > Is there a way of calculating Standard Deviation (STDDEV) using
> > > similar technique ?
> > > How about Firebird capabilities in this area ?
> > >
> > > Mario
> > ------- End of Original Message -------