Like in the title, I'm searching for the AR(p) or MA(q) or ARMA(p,q) input for lavaan package which will be right.
I've already go trough some books, but I didn't understand how to do it completly right. Some book also is saying that parameters of autoregressive model change which isn't true for me.
ar2_model <- '# Regresions:
x3 ~ p1*x2 + p2*x1
x4 ~ p1*x3 + p2*x2
x5 ~ p1*x4 + p2*x3
x6 ~ p1*x5 + p2*x4
x7 ~ p1*x6 + p2*x5'
The ARMA(p,q) processes have also estimating errors which have 0 mean and the same constant variance for all of them which I think isn't described in the model
Related
I am working on a SQL server project to make conversion between two types of car prices (eg, x is the original price, y is the dealer asking price) based on some rules, so that for every given dealer asking price y, I can get a corresponding original price x. The conversion rule I am having trouble with is this one: x + 5*ceiling(x/100) + some constant c = y, x=?
(It's more of a math problem actually. For example, if the rule is as easy as x + 10 = y, then x = y-10.)
Indeed, it's a math problem, that should be asked on Mathematics Stack Exchange.
That said, note that in the equation x+ceil(x)+c=y, x and y-c differ only by an integer (that depends on x). And since x+ceil(x) is an increasing function of x, if there is a solution it's unique.
Another remark:
for x in (0,1], x+ceil(x) lies in (1,2].
for x in (1,2], x+ceil(x) lies in (3,4].
...
That is, there is a solution only if y-c is in (2n-1,2n] for some integer n. And then, x=y-c-n.
How do we find n? Well, y-c in (2n-1,2n] iff (y-c)/2 in (n-1/2,n]. So we must have n=ceil((y-c)/2).
It's not much more difficult for the equation x+5ceil(x/100)=y-c.
Now,
for x in (0,100], x+5ceil(x/100) in (5,105]
for x in (100,200], x+5ceil(x/100) in (110,210]
...
for x in (100(n-1), 100n], x+5ceil(x/100) in (105n-100,105n]
Again, some values can't be reached, and if there is a solution, it's unique.
And if y-c lies in (105n-100,105n] for some n, then x=y-c-5n.
Of course, you want to find n. Note that y-c in (105n-100,105n] iff (y-c)/105 is in (n-100/105,n], which is a subset of (n-1,n]. So if there is a solution, you must have n=ceil((y-c)/105).
Not a complete answer but for the simple case of
Y = X + Ceiling(X)
declare #X float = 3.7
declare #Y float = 0.0
SELECT #y = #x + ceiling(#x)
SELECT CASE
WHEN (#y -floor(#y)) = 0 THEN #y/2
ELSE (#y - (#y -floor(#y)) - 1)/2 + (#y -floor(#y))
END XValue
This works for all values of X that I've tested. The first case is for when X is a whole integer.
EDIT
For your case of Y = X + 5*CEILING(X)/100 we can surmise that if X is an integer then Y = X + 5/100 * X => 1.05 * X, if X is not an integer then y = X + 5/100(X+1) => 1.05*X + 0.05
So I think the following works for your case:
declare #X float = 3.1
declare #Y float = 0.0
SELECT #y = #x + 5*ceiling(#X)/100
SELECT CASE WHEN (ROUND(#y/1.05,0) = #y/1.05) THEN #y / 1.05
ELSE ROUND((#y - 0.05) / 1.05,2) END
For your case with a constant, I can't see how to solve this without knowing the constant.
I am trying to replicate in my own code, not using ffmpeg libraries, the operations that ffmpeg does to convert yuv420p to rgb. Initially I thought it would be inside the function: xyz12Torgb48 in swscale.c but doing some tracing , it looks to be in yuv2rgb.c ff_yuv2rgb_c_init_tables, which I can not quite see it.
well, since nobody came out with a solution , I am just gonna post that I found using
valgrind tool=callgrind ffmpeg_g
which is a version of ffmpeg with debug objects that showed me the functions being called and inside \libswscale\x86 there is yuv2rgb_template.c which seems to have the operations you do yuv2rgb , in assembly
* Conversion is performed in usual way:
* R = Y' * Ycoef + Vred * V'
* G = Y' * Ycoef + Vgreen * V' + Ugreen * U'
* B = Y' * Ycoef + Ublue * U'
*
* where X' = X * 8 - Xoffset (multiplication is performed to increase
* precision a bit).
* Since it operates in YUV420 colorspace, Y component is additionally
* split into Y1 and Y2 for even and odd pixels.
*
* Input:
* mm0 - U (4 elems), mm1 - V (4 elems), mm6 - Y (8 elems), mm4 - zero register
* Output:
* mm1 - R, mm2 - G, mm0 - B
*/ ```
I am working on some software where I need to do large aggregation of data using SQL Server. The software is helping people play poker better. The query I am using at the moment looks like this:
Select H, sum(WinHighCard + ChopHighCard + WinPair + ChopPair + Win2Pair + Chop2Pair + Win3OfAKind + Chop3OfAKind + WinStraight + ChopStraight + WinFlush + ChopFlush + WinFullHouse + ChopFullHouse + WinQuads + ChopQuads + WinStraightFlush + ChopStraightFlush) / Count(WinStraightFlush) as ResultTotal
from [FlopLookup].[dbo].[_5c3c3d]
inner join[FlopLookup].[dbo].[Lookup5c3c3d] on [FlopLookup].[dbo].[Lookup5c3c3d].[id] = [FlopLookup].[dbo].[_5c3c3d].[id]
where (H IN (1164, 1165, 1166) ) AND
(V IN (1260, 1311))
Group by H;
This works fine and is the fastest way I have found to do what I am trying to achieve. The problem is I need to enhance the functionality in a way that allows the aggregation to include multiple instances of V. So for example in the above query instead of it just including the data from 1260 and 1311 once it may need to include 1260 twice and 1311 three times. But obviously just saying
V IN (1260, 1260, 1311, 1311, 1311)
won't work because each unique value is only counted once in an IN clause.
I have come up with a solution to this problem which works but seems rather clunky. I have created another lookup table which just takes the values between 0 and 1325 and assigns them to a field called V1 and for each V1 there are 100 V2 values that for e.g. for V1 = 1260 there is a range from 126000 through to 126099 for the V2 values. Then in the main query I join to this table and do the lookup like this:
Select H, sum(WinHighCard + ChopHighCard + WinPair + ChopPair + Win2Pair + Chop2Pair + Win3OfAKind + Chop3OfAKind + WinStraight + ChopStraight + WinFlush + ChopFlush + WinFullHouse + ChopFullHouse + WinQuads + ChopQuads + WinStraightFlush + ChopStraightFlush) / Count(WinStraightFlush) as ResultTotal
from [FlopLookup].[dbo].[_5c3c3d]
inner join[FlopLookup].[dbo].[Lookup5c3c3d] on [FlopLookup].[dbo].[Lookup5c3c3d].[id] = [FlopLookup].[dbo].[_5c3c3d].[id]
inner join[FlopLookup].[dbo].[VillainJoinTable] on [FlopLookup].[dbo].[VillainJoinTable].[V1] = [FlopLookup].[dbo].[_5c3c3d].[V]
where (H IN (1164, 1165, 1166) ) AND
(V2 IN (126000, 126001, 131100, 131101, 131102) )
Group by H;
So although it works it is quite slow. It feels inefficient because it is adding data multiple times when what would probably be more appropriate is a way of doing this using multiplication, i.e. instead of passing in 126000, 126001, 126002, 126003, 126004, 126005, 126006, 126007 I instead pass in 1260 in the original query and then multiply it by 8. But I have not been able to work out a way to do this.
Any help would be appreciated. Thanks.
EDIT - Added more information at the request of Livius in the comments
H stands for "Hero" and is in the table _5c3c3d as a smallint representing the two cards the player is holding (e.g. AcKd, Js4h etc.). V stands for "Villain" and is similar to Hero but represents the cards the opponent is holding similarly encoded. The encoding and decoding takes place in the code. These two fields form the clustered index for the _5c3c3d table. The remaining field in this table is Id which is another smallint which is used to join with the table Lookup5c3c3d which contains all the equity information for the hero's hand against the villain's hand for the flop 5c3c3d.
V2 is just a field in a table I have created to try and resolve the problem described by having a table called VillainJoinTable which has V1 (which maps directly to V in _5c3c3d via a join) and V2 which can potentially contain 100 numbers per V1 (e.g. when V1 is 1260 it could contain 126000, 126001 ... 126099). This is in order to allow me to create an "IN" clause that can effectively have multiple lookups to equity information for the same V multiple times.
Here are some screenshots:
Structure of the three tables
Some data from _5c3c3d
Some data from Lookup5c3c3d
Some data from VillainJoinTable
I am trying to run the with-as example on slide 22 from
http://www.postgis.us/downloads/oscon2009_PostGISTips.pdf
When I paste the example in the SQL-shell I get the following error:
ERROR: operator does not exist: record - integer LINE 14: ... x, y,
ST_SetSRID(ST_MakeBox2d(ST_Point(xmin + (x - 1)*g_wid...
HINT: No operator matches the given name and argument type(s). You might need to add
explicit type casts
I am using POSTGIS 1.4.1 with Postgres 8.4
I used the data that accompany the slides
http://www.bostongis.com/downloads/oscon2009/oscon2009_src.zip
I also tried the states data from the web with:
shp2pgsql -s 2163 statesp020.shp public.states > states.sql
psql -U postgres -d postgis -f states.sql
But got same error.
Any advice will be much appreciated.
The error "record - integer" (x - 1) can be fixed by giving the result from generate_series the intended aliases x and y. Find this part:
...
(SELECT generate_series(1,x_gridcnt) FROM usext) As x CROSS JOIN
(SELECT generate_series(1,y_gridcnt) FROM usext) As y CROSS JOIN
...
where the x and y values were actually called x.generate_series and y.generate_series.
Change this to:
...
(SELECT generate_series(1,x_gridcnt) As x FROM usext) As x CROSS JOIN
(SELECT generate_series(1,y_gridcnt) As y FROM usext) As y CROSS JOIN
...
where they are now called x.x and y.y, or implied as just x and y.
So I have the following MDX query which runs against the AdventureWorks example cube.
SELECT NON EMPTY ([Date].[Fiscal Semester of Year].[Fiscal Semester of Year],{[Measures].[Internet Order Count], [Measures].[Average Unit Price]}) ON 0,
NON EMPTY([Product].[Status].[Status] ,[Customer].[Country].[Country]) ON 1
FROM [Adventure Works]
This gives a result which looks a bit like:
H1 H2 H1 H2
X1 X2 X1 X2 X1 X2 X1 X2
A A1
A A2
A A3
B A1 numbers
B A2
B A3
The CellSet has various bits of metadata, but none of it describes that structure, as far as I can tell. It doesn't seem to include useful things like Measure names or Dimension names, etc.
Any clues? If I execute the above query in Management Studio it formats it nicely for me. Is that because it is being clever with its parsing of the MDX, or because it is accessing some metadata I haven't found yet?
As an aside, I can query the cube via the connection and get lots of cube related info that way, but I need a way to relate that back to my query result.
The chances are I will have a CellSet, but not the source MDX that generated it.
Thanks
Try something like this:
CellSet cs = cmd.ExecuteCellSet();
Axis columns = cs.Axes[0];
TupleCollection columnTuples = columns.Set.Tuples;
for (int i = 0; i < columnTuples.Count; i++)
{
string caption = columnTuples[i].Members[0].Caption;
}
Axis rows = cs.Axes[1];
TupleCollection rowTuples = rows.Set.Tuples;
foreach (Position rowPos in rows.Positions)
{
string caption = rowTuples[rowNum].Members[0].Caption;
}