# How to generate random variable theta for F(theta)=N(1 - (mu*B)/(k*​T)*cos(the​ta)). For N=1 and mu*B/k*T=0.01

3 views (last 30 days)
Souhail on 22 Jul 2022
Commented: Walter Roberson on 22 Jul 2022
Hello everyone,
Im trying to generate random theta numbers from a uniform distribution (Inverse Tranformation Method), my equation F(theta)=N(1 - (mu*B)/(k*T)*cos(theta)) is called Boltzmann Distribution. I will be happy If someone can help me! the Figure I should get, looks like this ##### 2 CommentsShowHide 1 older comment
Souhail on 22 Jul 2022
@Dyuman Joshi Thank you for you reply, I already tried to plot it, but its not that easy, when I plot it I dont get the desire graph

Dyuman Joshi on 22 Jul 2022
syms theta
fplot(1-0.01*cosd(theta))
xlim([0 180])
ylim([0.99 1.015]) Walter Roberson on 22 Jul 2022
Edited: Walter Roberson on 22 Jul 2022
syms mu B k T theta
f(theta) = 1 - (mu*B)/(k*T)*cosd(theta)
f(theta) = x = rand(1,5) * 180
x = 1×5
155.8450 168.7684 129.4596 95.2868 64.1594
f(x)
ans = vpa(ans)
ans = ##### 2 CommentsShowHide 1 older comment
Walter Roberson on 22 Jul 2022
In the code I posted, you would not be able to plot until you had substituted in actual values for the variables such as B mu T k