Flow of Control Statement...eviews - eviews

i am having a simple problem ,i am sure the solution is easy but , i am not able to solve it .
however when i operate :
smpl 1 500
genr u1=nrnd*4
genr u2=nrnd*5
genr serix =.1
genr serix =.1
genr seriy=.1
for !i=2 to 500
smpl !i !i
serix=17.129+0.00676*serix(-1)+0.6125*seriy(-1)+ u1
serix=12.863+0.1756*serix(-1)+0.2992*seriy(-1)+ u2
it shows an error , in the "for" instruction
enter image description here
it says "Flow of Control Statement..."

Try this
create Test u 500
mode quiet
smpl 1 1
series x=0.1
series y=0.1
for !i=2 to 500
!u1=#nrnd*4
!u2=#nrnd*5
smpl !i !i
series x=17.129+0.00676*x(-1)+0.6125*y(-1)+ !u1
series y=12.863+0.1756*x(-1)+0.2992*y(-1)+ !u2
next !i
smpl #all

Related

Conditional Regex for multiple matches in a line

I've got a regex that is responsible for matching the pattern A:B in lines where you might have multiple matches (i.e. "A:B A: B A : B A:B", etc.) The problem lies in the complexity of what A represents.
I'm using the regex:
\b[\w|\(|\)+]+\s*:(?:(?![\w+]+\s*:).)*
to match items in:
Data_1: Tutor Elementary: 10 a F Test: 7.87 sips
Turning 1 Data (A Run), Data: 0.0 10.0 10.0 17.3 0.0
Turning 2 Data (A Run), Data2: 0.0 6.8 0.0 6.8 6.8
Data_1: Tutor Pool: Data2: A B C
Turning 2 (A Run), ABSOLUTE: 368 337 428 0 2 147
Data_4 : 4AZE Localization : 33.14 lat -86 long
Time: 0.75 Data Scenario: 3121.2
The question is this, if you examine this setup (I use https://regex101.com/), lines 2,3,5 don't return exactly what I'm looking for. Where the match is the first in the line, I want it to grab everything from the beginning of the line to the first ':'. Is this type of conditional regex possible? I've tried every possible way I could imagine, but I haven't been successful yet.
Thanks in advance!
A little complex, but try this here
^(.*?:.*?)(\b\w+\b\s*:.*?)\b\w+\b:.*$|^(.*?:.*?)\b\w+\b\s*:(.*?)$|^(.*)$

Merge Time Series in Apache Pig

I think my problem is trivial, but I'm new to Pig and I can't see an obvious answer in the documentation. I have two time series I wish to merge. Let's say one of them is just a stream of events X:
100 A
200 B
300 C
400 D
500 E
600 F
Then another one indicates when some state changes happen, call it Y.
50 on
250 off
350 on
450 off
I would like to tag the first time series X with the current on/off status from Y. So specifically I want:
100 A on
200 B on
300 C off
400 D on
500 E off
600 F off
If I was writing this in another language I might do something like merge sort X and Y and take a single pass through it, remembering the last on/off status and tagging the X entries.
What is the best way to do this in Pig? I have received some existing code which uses a JOIN of X and Y and then filters it, but I think the data inflation caused by the join is unnecessary.
I don't think there is a very easy solution. Here is some pseudo-code:
X1 = Rank X;
Y1 = Rank Y;
XY = JOIN X1 BY BY $0 LEFT OUTER, Y1 BY $0;
SPLIT XY INTO status_known IF status is not null, status_unknown OTHERWISE;
--Y2: Find out last status in Y1 (with Group all, max)
--Y3: Cross status_unknown with Y2
UNION status_known and Y3

Solve error: Fortran runtime error: Bad integer for item 0 in list input

I have recently changed my f90 editor to CodeBlocks for Mac OS X, and when I try to open a file located in the project folder to read the data, the next error message appears on screen when the code is run:
Fortran runtime error: Bad integer for item 0 in list input
I have introduced the same code I used to write in Windows 7 using the intel compiler for fortran and Visual Studio.
The code itself is:
subroutine read_input_data
use input_data
implicit none
integer i,j
open(UNIT=5, FILE='lifting_line_input_data.txt', STATUS='old', FORM='formatted', ACCESS='sequential')
read(5,*) C
read(5,*) U
read(5,*) alpha
read(5,*) rho
read(5,*) wake_length
read(5,*) wake_eps
read(5,*) n_chord
read(5,*) n_twist
if (n_chord .GE. n_twist ) then
i = n_chord
else
i = n_twist
end if
allocate(chord_twist(5,i))
do j = 1, i
read(5,*) chord_twist(:,j)
end do
close(5)
end subroutine read_input_data
Could you help me to solve this problem? Thank you very much.
PD. the data file is obtain from an Excel sheet saved as a .txt delimited by tabulations
! LIFTING-LINE WING
! Number of panels
6
! Free stream speed [m/s]
50
! Angle of attack [rad]
0.15
! Air density [kg/m^3]
1.225
! Wake length [m]
100
! Convergence parameter
0.01
! Number of data points given for the chord distribution
2
! Number of data points given for the twist distribution
2
! Y coord [m] ! X_LE [m] ! X_TE [m] ! Y coord [m] ! Twist [rad]
0 0 2 0 0
10 0 0.5 10 0.052359878
PD2. I have change the format of the .txt file to make it equal to the input files I had used in Visual Studio. Now the file is:
6 ! Number of panels
50 ! Free stream speed [m/s]
0.15 ! Angle of attack [rad]
1.225 ! Air density [kg/m^3]
100 ! Wake length [m]
0.01 ! Convergence parameter
2 ! Number of data points given for the chord distribution
2 ! Number of data points given for the twist distribution
0 0 2 0 0 ! Y coord [m] ! X_LE [m] ! X_TE [m] ! Y coord [m] !Twist [rad]
10 0 0.5 10 0.052359878
And now the error given at the terminal is that the file is not found. As I am a beginner in CodeBlocks, I will explain what I have done step by step because I do not find where I am wrong and I am starting to get desperate:
New Project -> Fortran application -> I indicate where I want to create the project file.
I remove the main.f95 file and I add the .f90 file with the code.
I write the code.
I save the .txt file in the same folder than all the files of the Project.
When I run the code it appears the error message of file not found.
The code is:
!************************************************
subroutine read_input_data
use input_data
implicit none
integer i,j
open(UNIT=10, FILE='lifting_line_wing_input.txt', STATUS='old', ACCESS='sequential')
read(10,*) C
read(10,*) U
read(10,*) alpha
read(10,*) rho
read(10,*) wake_length
read(10,*) wake_eps
read(10,*) n_chord
read(10,*) n_twist
if (n_chord .GE. n_twist ) then
i = n_chord
else
i = n_twist
end if
allocate(chord_twist(5,i))
do j = 1, i
read(10,*) chord_twist(:,j)
end do
close(10)
end subroutine read_input_data
!************************************************
Thank you very much for your time and help
This looks like your old system did something non-standard with exclamation marks on list-directed input.
Try reformatting your input data like
6 / number of panels
(the slash will terminate the READ).
i don't believe any fortran compiler ever automagically handled those comments.
If you want to read this file the way it is, one approach is to make each read handle the error, eg,
integer ios
ios = 1
do while(ios.ne.0)
read(unit,*,iostat=ios)c
end do
ios=1
do while(ios.ne.0)
read(unit,*,iostat=ios)u
end do
etc..
if its a one-off you could just edit the file and delete all the comments as well.

Fortran read data with different length

I have a Fortran problem. I want to read in data with different length.
they begin with:
<TITLE>University of Wyoming - Radiosonde Data</TITLE>
<LINK REL="StyleSheet" HREF="/resources/select.css" TYPE="text/css">
<BODY BGCOLOR="white">
<H2>08190 Barcelona Observations at 12Z 11 Feb 2015</H2>
<PRE>
-----------------------------------------------------------------------------
PRES HGHT TEMP DWPT RELH MIXR DRCT SKNT THTA THTE THTV
hPa m C C % g/kg deg knot K K K
-----------------------------------------------------------------------------
1012.0 98 14.0 -1.0 36 3.53 0 0 286.2 296.5 286.8
from this point the file is for example 77 lines long. but others have only 55 , and the end is reached when this part comes
</PRE><H3>Station information and sounding indices</H3><PRE>
Station number: 8190
So I think I need a condition which runs out of the do loop?
I get my data with :
wget 'http://weather.uwyo.edu/cgi-bin/sounding?region=europe& TYPE=TEXT%3ALIST&YEAR=2015&MONTH=02&FROM=1112&TO=1112&STNM=08190' -0 data.dat
open(33, file=infilename, form='formatted',&
access='sequential',action='read')
open(34, file=outfilename, form='formatted',&
access='sequential',action='write')
read(33,'(11/)')
do i=1,77
read(33, '(f7.1,2x,i5,2x,a5,2x,a5,4x,a3,3x,f4.2,4x,a3,4x,a3)') pres,height,tmp,tmp_dew,rel_hum,mixing,wind_dir,wind_speed
write(34,'(f7.1,2x,i5,2x,a5,2x,a5,4x,a3,3x,f4.2,4x,a3,4x,a3)') pres,height,tmp,tmp_dew,rel_hum,mixing,wind_dir,wind_speed
end do
close(33)
close(34)
I hope you can help me.
one approach is to read each line as a string, check for the end and process accordingly:
character*1000 wholeline
do while( .true. )
read(33,'(a)')wholeline
if ( index(wholeline,'</PRE>' ).ne.0 )exit
read(wholeline,*)pres,height,tmp,tmp,dew ...
enddo
You can also perhaps more simply just read and exit on an error..
do while( .true. )
read(33,*,err=100)pres,height,tmp,tmp,dew ...
enddo
100 continue
I'm not a fan of deliberately throwing errors if it can be avoided though.
As an aside you do not need that messy format, list directed will work fine for this example. In fact if all you are doing is transferring the data to another file, simply rewrite the string as: write(34,'(a)')trim(wholeline)

How can I deal with Liblinear's output in c++?

I'm trying to get liblinear to work in c++, but the library call to train(problem*, parameter*) is sending output to the terminal. Sometimes it says the optimization finished, other times it seems to be outputting internal state (why?). What does this output mean, and is it possible to suppress it or divert it to a log somewhere? I'm using boost::log in the rest of the program, and I'd like to control what the program displays. I'm running this on Ubuntu 12.10.
example output:
iter 1 act -6.742e-01 pre 1.191e-02 delta 3.443e-02 f 5.940e-02 |g| 1.730e-01 CG 1
cg reaches trust region boundary
iter 1 act -3.040e-02 pre 5.211e-03 delta 8.607e-03 f 5.940e-02 |g| 1.730e-01 CG 1
cg reaches trust region boundary
iter 1 act 5.453e-04 pre 1.442e-03 delta 6.791e-03 f 5.940e-02 |g| 1.730e-01 CG 1
cg reaches trust region boundary
iter 2 act 6.299e-04 pre 5.985e-04 delta 8.812e-03 f 5.886e-02 |g| 2.525e-01 CG 2
cg reaches trust region boundary
iter 3 act 2.610e-04 pre 2.449e-04 delta 1.583e-02 f 5.823e-02 |g| 4.313e-02 CG 2
iter 4 act 1.510e-04 pre 1.585e-04 delta 1.583e-02 f 5.796e-02 |g| 2.927e-02 CG 4
or
..*
optimization finished, #iter = 25
Objective value = -0.332340
nSV = 173
for the train call, my parameters are:
solver_type = L2R_L2LOSS_SVR
eps = 0.001
C = 0.02
nr_weight = 0
weight_label = nullptr
weight = nullptr
p = 0.005
My input data has some 10,000 ~ 100,000 data points, each with 62 feautres.
Also, the output model has 124 weights.. I'm assuming that's 62 weights for the set represented by the positive labels and 62 for the negative labels? How do I know which order they are in? model->label is NULL for my solver_type.