Really , am confused and mixed in the same time , I have tried to plot the Histogram of my PDF which it is already integrated to 1 (Normalised) , I didn't succeed to compute anything related to that PDF only Moment the response of wolfram cloud was "pdfF[#1][z] is not regognized by the system" , Now I have added this commond to generate my Histogram Plot :pdfF[#1][z]=NormalDistribution[]

From the latter commond i become able to do all thing related to my PDF distribution, For example I have plot my Histogram with Normal Distribution Histogram in unified Graph as shown below using thr following Code:

data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[pdfF[#1][z], 500];
Histogram[{data1, data2}]

Now My question here After seen the below Plot , Does what I have did for My PDF or for Normal Distribution ? Or what operation I did ?

enter image description here


Your "PDF" definition is neither a PDF nor a proper syntax for a function definition.

pdfF[#1][z] = NormalDistribution[]

(* NormalDistribution[0, 1] *)

Irrespective of the syntax error, your subsequent call returns a distribution, i.e., NormalDistribution[0, 1].

Your data1 and data2 are defined with the same distribution. Their values differ only because they each start with different random seeds. Resetting the random seed with SeedRandom would produce identical results.

data1 = RandomVariate[NormalDistribution[0, 1], 500];
data2 = RandomVariate[pdfF[#1][z], 500];

data1 === data2

(* True *)

The proper way to define a PDF and keep clear the difference between a distribution and a PDF

dist = NormalDistribution[0, 1];

pdf[z_] = PDF[dist, z]

(* E^(-(z^2/2))/Sqrt[2 π] *)

Or if you want a pure function

pdf2 = PDF[dist, #] &

(* PDF[dist, #1] & *)

Note that dist did not evaluate since Function has the attribute HoldAll


(* {HoldAll, Protected} *)

Both pdf and pdf2 give the same result

pdf[z] == pdf2[z]

(* True *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.