現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
1 投票
I have a variable containing a probability distribution (just an one-dimensional array of values). How can I normalize a to unit norm?
採用された回答
Wayne King
2012 年 5 月 27 日
If you want to normalize a vector to have unit L2 norm.
x = randn(100,1);
x = x./norm(x,2);
norm(x,2)
12 件のコメント
Nuchto
2012 年 5 月 27 日
Thanks, Wayne, for your quick reply :) However, I don't understand. My values in x should add up to 1, but I can't find the new array of elements in x with the new values that would add up to 1.
Oleg Komarov
2012 年 5 月 27 日
They're in ans.
Nuchto
2012 年 5 月 27 日
ANS is just a value (1), is not an array of values that add up to zero.
Oleg Komarov
2012 年 5 月 27 日
My mistake, ans proves that the x values are normalized to a unit L2 norm.
Nuchto
2012 年 5 月 27 日
when I sum(x) after the second line, the sum doesn't add up to 1.
Nuchto
2012 年 5 月 30 日
Help!!!
Oleg Komarov
2012 年 5 月 30 日
x./sum(x)
Now, this is not a unit norm normalization (as I understand it, thus nobody answered earlier).
Nuchto
2012 年 6 月 1 日
What is a unit norm normalization as you understand it?
Kye Taylor
2012 年 6 月 1 日
"Unit norm" itself is not well-defined without specifying the norm itself.
@Nuchto, it sounds like you are looking for the l1 norm, while the initial answer provided by @Wayne is using the l2 norm...
As @Oleg suggested, you can normalize by the sum to obtain the same as the following
normX = x/norm(x,1)
Be careful if simply normalizing by the sum because it doesn't account for negative values in the original vector. However, since you are working with a probability distribution, that isn't an issue.
Oleg Komarov
2012 年 6 月 1 日
"same as the following
normX = x/norm(x,1)"
IF all x >0.
Nuchto
2012 年 6 月 2 日
Thanks, it works now. What is in lay terms :) the difference between l1 and l2 norm?
Oleg Komarov
2012 年 6 月 2 日
http://en.wikipedia.org/wiki/Norm_%28mathematics%29, Euclidean vs taxicab
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Random Number Generation についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
