我試圖找到一些隨機數據的概率分佈。我可以在matlab中生成繪圖,但是如果我能夠以tabled格式獲得值,則會發現它更有用,因此我可以進行monte carlo模擬。如何獲得matlab中概率圖的值的表格形式?
1
A
回答
0
可以使用的hist
可選的輸出參數,像這樣得到的隨機數據的概率:
z=randn(10000,1); %# generate 10000 trials of a normally distributed random variable.
[f,x]=hist(z,100); %# get x values and bin counts (f)
prob=f/trapz(x,f); %# divide by area under the curve to get the
您可以輕鬆地驗證這給你的概率分佈。
bar(x,prob);hold on
plot(x,1/sqrt(2*pi)*exp(-(x.^2)/2),'r','linewidth',1.25);hold off
您可以使用uitable
上面的數據創建一個表。
data=num2cell([prob(:);x(:)]);
colNames={'Probability','x'};
t=uitable('Data',data,'ColumnName',colNames);
0
這可能是一個愚蠢的問題,但是,你有一個離散分佈(二項分佈,泊松分佈,......)或連續分佈的工作?如果您正在進行任何類型的連續分發,並添加一個步驟並將其表示爲離散分佈將導致麻煩。
即使您使用離散分佈,表格表示也是不必要的步驟。
下面是一些代碼,顯示了一個非常簡單的方法來做你想做的事情。
%% Parametric fitting, followed by random number generation
% Generate some random data from a normal distribution with mean = 45 and
% standard devation = 6
X = 45 + 6 * randn(1000,1);
foo = fitdist(X, 'normal')
% Use the object to generate 1000 random numbers
My_data = random(foo, 1000,1);
mean(My_data)
std(My_data)
%% Kernel smoothing, followed by random number generation
% Generate some random data
X = 10 + 5 * randn(100,1);
Y = 15 + 3 * randn(60,1);
my_dist = vertcat(X,Y);
% fit a distribution to the data
bar = fitdist(my_dist, 'kernel')
% generate 100 random numbers from the distribution
random(bar, 100, 1)
%% Fitting a discrete distribution
% Use a poisson distribution to generate a 1000 random integers with mean = 6.8
Z = poissrnd(6.8, 1000,1);
foobar = fitdist(Z, 'poisson')
% generate 100 random numbers from the distribution
random(foobar, 100, 1)
相關問題
- 1. 如何在Matlab中編程以獲得轉換概率矩陣?
- 2. Matlab中的概率組合
- 3. 如何將概率應用於MATLAB中的單元格?
- 4. 如何根據一定的概率獲得一個值
- 5. Matlab - 確定強度值的概率
- 6. 在Matlab中生成概率
- 7. 如何獲得R中每個條形圖的條形圖的頻率總計?
- 8. WEKA + Java的:獲得類的概率
- 9. 如何獲得matlab中示波器波形的實時繪圖?
- 10. ř獲得的概率分佈
- 11. BotFramework:獲得IntentDialog的概率分數
- 12. 如何使用matplotlib獲得密度/概率圖
- 13. 如何在外部形式呈現概念中獲取提交的表單值
- 14. matlab中的簡單概率代碼
- 15. Matlab中的狄拉克概率測度
- 16. 獲取概率中的R
- 17. 如何獲得最接近的表格形式使用給ajaxForm
- 18. Weka:如何獲得測試實例的每個類的概率
- 19. 如何用概率列表高效地計算二項式概率? R中
- 20. 以有限的方式獲得一致的概率分佈
- 21. 蟒蛇如何獲得字符串形式的列表值
- 22. matlab概率分佈擬合
- 23. 如何獲得每個主題的概率槌
- 24. 如何獲得使用Mallet查詢的主題概率
- 25. 如何獲得預測的類而不是類概率?
- 26. Matlab Black Scholes公式如何從B&S價格獲得波動率
- 27. 如何在多類分類中獲得jlibsvm預測概率
- 28. 獲得一個表達的極性和笛卡爾形式MATLAB
- 29. 我如何獲得matlab中.wav(音頻)文件的多項式形式
- 30. 對期望值的概率拼圖