【发布时间】:2023-04-03 11:12:01
【问题描述】:
我正在尝试读取一个巨大的文本文件并计算每个字母的频率,然后我想找到每个字母的概率分布。 这是我目前正在尝试的:
f = fopen('c:\words.txt');
ns = textscan(f, '%s');
fclose(f);
counts = hist(num, 1:26);
prob = counts / numel(ns{:})
任何提示、帮助、工作代码?
我也在尝试这段代码,但答案不准确
fid = fopen('c:\words.txt');
c = fread(fid);
fclose(fid);
y = unique(c);
counts = histc(c, y);
我想得到如下结果:
a = 2338 times
b = 4533 times
c = 1233 times
等等……
问候,
【问题讨论】:
-
有多大?你的意思是太大了,需要分小块阅读?
标签: matlab probability