Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:05:36+00:00 2026-06-06T01:05:36+00:00

I have the following data X Y INFTIME 1 1 0 1 2 4

  • 0

I have the following data

X     Y    INFTIME
1     1     0
1     2     4
1     3     4
1     4     3
2     1     3
2     2     1
2     3     3
2     4     4
3     1     2
3     2     2
3     3     0
3     4     2
4     1     4
4     2     3
4     3     3
4     4     0

X and Y represent he X and Y components in the square grid of 4 by 4.
Here I want to sample randomly 10% from the population which are infected i.e, whose INFTIME is non zero. I did not get any idea of coding so could not start it.
Any suggestions and idea will be great for me.
Thanks

EDIT:

DO T = 1,10
   DO i = 1, 625

      IF(INFTIME(i)/=0 .AND. INFTIME(i) .LE. T)THEN
         CALL RANDOM_NUMBER(u(i))
         u(i) = 1+aint(u(i)*25)
          CALL RANDOM_NUMBER(v(i))
         v(i) = 1+aint(v(i)*25)
          CALL RANDOM_NUMBER(w(i))
         w(i) = 1+aint(w(i)*10)
      ENDIF
   ENDDO
ENDDO


do p = 1,625
  WRITE(*,*) u(p),v(p),w(p)
 enddo

This is my code what I tried but it only gives the random numbers, not the connection to the data. I used the data of 25 by 25 grids i.e, 625 individuals and time of infection 1 to 10

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:05:38+00:00Added an answer on June 6, 2026 at 1:05 am

    Follow what ja72 said. You have three 1D arrays of the same size (16). All you need to do is pick a number between 1 and 16, check to see if INFTIME is zero and accept the value as needed, then repeat until you’ve taken 10% of the samples (which would be 1.6 values, so I presume you’d just take 2? Or do you have more data than this 4×4 you presented?)

    Edit You need to call the random number generator before the if statement:

        do t=1,10
          do i=1,625
              ind = 1+int(624*rand(seed))
              if(inftime(ind).neq.0 .and. inftime(ind).le.t) then
                 stuff
              endif
           enddo
        enddo
    

    The call ind=1+int(625*rand(seed)) will pick a random integer between 1 (when rand(seed)=0) and 625 (when rand(seed)=1). Then you can do what you need if the if statement is satisfied.

    EDIT: program epimatrix

    IMPLICIT NONE
    INTEGER ::l, i,T,K
    REAL, DIMENSION(1:625):: X,y,inftime
    INTEGER::seed,my_cnt
    INTEGER,DIMENSION(8) :: time1
    CALL DATE_AND_TIME(values=time1)
    seed = 1000*time1(7)+time1(8)
    call srand(seed)
    
    OPEN(10, FILE = 'epidemicSIR.txt', FORM = 'FORMATTED')
    DO l = 1,625
       READ(10,*,END = 200) X(l), Y(l), INFTIME(l)
      ! WRITE(*,*) X(l),Y(l), INFTIME(l)
      ! if you know how it was formatted, you should use
      ! read(10,20) X(l), Y(l), INFTIME(l)
      ! where 20 is the format
    ENDDO
    200 CONTINUE
    CLOSE(10)
    
    DO T = 1,10
       my_cnt=0
       write(*,*) "T=",T
       DO while (my_cnt.le.63)
          K = 1+int(624*rand())
          IF(INFTIME(K)/=0 .AND. INFTIME(K) .LE. T)THEN
             write(*,*) X(k),Y(k),INFTIME(k)
             my_cnt=my_cnt+1
          ENDIF
       enddo
       write(*,*) " "
    ENDDO
    
    end program
    

    EDIT 2
    I’ve adjusted the program to fix some of the issues. I’ve tried keeping my edits in lowercase so that you can see the difference. The do-while loop allows the code to continue running until the condition my_cnt.le.63 has been met (which means you have 63 lines of X, Y, inftime per T). I’ve added a line to output T and another line to add a space so that the data might be more clear when looking at the output.

    This should take care of all the issues you’ve been running into. If not, I’ll keep checking this page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following json data which I want to pass it to server using
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
I have the following data from 2 tables Notes (left) and scans (right) :
I have the following data - it is a dump from a normalized database,
I have the following data in a database table, Columns : Date, Hour(from 1
I have following CSV data: 10,11,12.34 I can parse this using CSV from the
I have the following data structure or record, which I need to stream to
I have the following data and i am using http://commons.apache.org/jxpath/ i want to directly
I have the following data scheme that I want to turn into an application.
I have following data: Dictionary<string,string> dctParameters = new Dictionary(){ {a,var1},{b,var2},{c,var3},.... } I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.