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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:59:45+00:00 2026-05-16T15:59:45+00:00

I am trying to translate a function in a book into code, using MATLAB

  • 0

I am trying to translate a function in a book into code, using MATLAB and C#.

I am first trying to get the function to work properly in MATLAB.

Here are the instructions:

alt text

The variables are:

xt and m can be ignored.
zMax = Maximum Sensor Range (100)
zkt = Sensor Measurement (49)
zkt* = What sensor measurement should have been (50)
oHit = Std Deviation of my measurement (5)

I have written the first formula, N(zkt;zkt*,oHit) in MATLAB as this:

hitProbabilty = (1/sqrt( 2*pi * (oHit^2) ))...
                * exp(-0.5 * (((zkt- zktStar) ^ 2) / (oHit^2))  );

This gives me the Gaussian curve I expect.

I have an issue with the definite integral below, I do not understand how to turn this into a real number, because I get horrible values out my code, which is this:

func = @(x) hitProbabilty * zkt * x;
normaliser = quad(func, 0, max) ^ -1;  
hitProbabilty = normaliser * hitProbabilty;

Can someone help me with this integral? It is supposed to normalize my curve, but it just goes crazy…. (I am doing this for zkt 0:1:100, with everything else the same, and graphing the probability it should output.)

  • 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-16T15:59:46+00:00Added an answer on May 16, 2026 at 3:59 pm

    You should use the error function ERF (available in basic MATLAB)


    EDIT1:

    As @Jim Brissom mentioned, the cumulative distribution function (CDF) is related to the error function by:

    normcdf(X) = (1 + erf(X/sqrt(2)) / 2 ,   where X~N(0,1)
    

    Note that NORMCDF requires the Statistics Toolbox


    EDIT2:

    I think there’s been a small confusion seeing the comments.. The above only compute the normalizing factor, so if you want to compute the final probability over a certain range of values, you should do this:

    zMax = 100;                         %# Maximum Sensor Range
    zktStar = 50;                       %# What sensor measurement should have been
    oHit = 5;                           %# Std Deviation of my measurement
    
    %# p(0<z<zMax) = p(z<zMax) - p(z<0)
    ncdf = diff( normcdf([0 zMax], zktStar, oHit) );
    normaliser = 1 ./ ncdf;
    
    zkt = linspace(0,zMax,500);         %# Sensor Measurement, 500 values in [0,zMax]
    hitProbabilty = normpdf(zkt, zktStar, oHit) * normaliser;
    
    plot(zkt, hitProbabilty)
    xlabel('z^k_t'), ylabel('P_{hit}(z^k_t)'), title('Measurement Probability')
    

    alt text

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

Sidebar

Related Questions

I'm trying to translate the usage of find function in Matlab to C++ .
I'm trying to translate Brandon Kelly's AC.VR class (Prototype) into a jQuery plugin. Here
I'm trying to translate Brandon Kelly's AC.VR class (Prototype) into a jQuery plugin. Here
I've got a code snippet of c# that I've been trying to translate into
I'm trying to translate a javascript function into php but having some problems with
I am trying to translate the VBA code found in this link into IronPython.
I'm trying 'translate' the sample code in here , but i can't find equivalent
I am trying to translate the Javascript function here. This will produce a cardinal
I am trying to get a grasp on Haskell using the online book Learn
when trying to translate the confirmation message to Norwegian i get the following error:

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.