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 3981514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:25:08+00:00 2026-05-20T05:25:08+00:00

I did these so far: EDIT————— steps=@ (m) 2*randi([0,1],[1,m])-1; Walk1D =@ (n) [0,cumsum(steps(n))]; findend=@

  • 0

I did these so far:

EDIT—————

steps=@ (m) 2*randi([0,1],[1,m])-1;
Walk1D =@ (n) [0,cumsum(steps(n))];
findend=@ (x) x(end);
LastPoint1D=@(n) findend(Walk1D(n));

nsteps=200;
nsq=floor(sqrt(nsteps));
MeanSquareDistance1D= @ (n,m) m.*sum((LastPoint1D(n)).^2)./m;
r2D=MeanSquareDistance1D(100,1000)

data=[ ];
for i=10:20:90
data=[data; i , MeanSquareDistance1D(i,2000)]
end

The only problem now,is that the 2nd column of “data” must give me values around

10
30
50
70
90

but not exactly.Only approximately.For example ,the “data” must be:

10  10.184
30  27.51
50  50.306
70  68.394
90  90.414

Sth is wrong with the sum maybe?

  • 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-05-20T05:25:09+00:00Added an answer on May 20, 2026 at 5:25 am

    From your code I guess you want to calculate the mean squared distance for a 1D random walk.

    The mean squared distance at lag tt is the average squared difference between two positions along the random walk separated by tt steps. I assume that data should be an array where the first column is tt and the second column the corresponding mean squared distance, and where there is an additional parameter that indicates the total number of steps in your random walk.

    Here’s how I’d calculate data

    %# define parameters
    nSteps = 2000;
    listOfLags = 10:20:90; %# must be 1-by-n vector
    
    %# create random walk
    %# steps can be +1 or -1, add all of them via cumsum
    randomWalk = cumsum(randi([0 2],nSteps)-1);
    
    %# calculate msd for the desired lags
    %# use a loop for readability
    nLags = length(listOfLags);
    data = zeros(nLags,2);
    data(:,1) = listOfLags;
    
    for lag = listOfLags
        %# lag takes on every lag value, so use logical indexing to find
        %# which lag (in terms of entry into data) we're currently working on
    
        %# This line corresponds to
        %# 1. get all distances traveled within a duration of `lag`
        %#    vectorOfDistances = randomWalk(lag+1:end) - randomWalk(1:nSteps-lag)
        %#    i.e. the first element is randomWalk(lag+1)-randomWalk(1)
        %# 2. square all: (vectorOfDistances).^2
        %# 3. average all squared distances 
        data(listOfLags==lag,2) = mean( (randomWalk(lag+1:end) - randomWalk(1:end-lag)).^2);
    end
    
    %# plot the results
    plot(data(:,1),data(:,2),'.')
    xlabel('lag'),ylabel('mean squared displacement')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did not have luck with these examples: Javascript File remove Javascript FSO DeleteFile Method
I did an import using impdp. Afterwards I found these errors in the log
I am new to jquery. I did come across http://komunitasweb.com/2009/09/3-amazing-jquery-color-picker-plugins/ but these plugins are
EDIT: See end of my post for working code, obtained from zeekay here .
Edit 1 (clarification): Thank you for the answers so far! The response is gratifying.
[Edit] Here's what I've gleaned about mouse input handling thus far. Note that I've
I just did one of those auto updates of the Android SDK (API 15
[Note: There is another thread about this problem but it did not answer the
I did a little bit of Web Programming here and there but I never
Is there any minimum compute capability to use CUDA-OpenGL interoperability? I did not find

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.