I will like to write a code for values of x = (-0.1, 0.0, 0.1)
write code to calculate L (x ; mu = 0, sigma = 1)
In R code (L <-function(x, u=0, s2=1)(sqrt(2*pi*s2))^-1*exp(-(x-u)^2/(2*s2))
x<-c(-0.1,0.0, 0.1)
L(-0.1)
L(0.0)
L(0.1)
Thanks
what have you tried, please post more than just your assignment.
How to create a data-step version of your data
https://communities.sas.com/t5/help/faqpage/faq-category-id/posting#posting
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...
How to Add attachments
https://communities.sas.com/t5/Community-Memo/Adding-attachments-to-your-communities-posts/ba-p/4647...
Thanks to everyone who helped me have a better understanding of how this works.
Try PDF() function. And post it at IML forum , calling @Rick_SAS
As KSharp points out, your function is the PDF of the normal distribution. The PDF function is one of several built-in functions for working with probability distributions, so you can just call the PDF function directly. You can call it from the DATA step or from PROC IML:
data Want;
do x = -0.1 to 0.1 by 0.1;
y = pdf("Normal", x); /* default is u=0, s=1 */
output;
end;
run;
proc print; run;
proc iml;
x = {-0.1, 0, 0.1};
y = pdf("Normal", x); /* default is u=0, s=1 */
print x y;
If the goal of the exercise is to define a SAS/IML function module. see the article "Everything you wanted to know about writing SAS/IML modules." which discusses how to define functions and how to define default arguments.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.