I have a fraction that I am multiplying by an array of data to create a new array, but I want the new array of data to have error for the new values.

댓글 수: 2

KSSV
KSSV 2020년 12월 3일
Add some random noise....? Question is not clear.
Justin Holladay
Justin Holladay 2020년 12월 3일
I have an array of data for the number of traffic collisions from 1979-2018.
I have data from 2018 that shows the number of traffic collisions caused by speeding. I took speeding caused traffic collisions divided by total number of collisions for 2018 to get a percentage. I want to apply that percentage to the data from 1979-2018 to retrieve a set of data for number of traffic collisions caused by speeding for each of those years. I want the data to have error so that it is not following the exact percentage for each data point.

댓글을 달려면 로그인하십시오.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 12월 3일

0 개 추천

What type of noise you you want to add? Following shows an example with normally distributed noise.
acc79_18; % data from 1979 to 2018
acc_speed_18; % speed accident in 2018
percent = acc_speed_18/acc79_18(end); % calculate fraction
percent_all_years = per*ones(1,numel(acc79_18)) + 0.01*randn(); % normally distributed noise with std of 0.01
percent_all_years(end) = per; % for 2018, noise should not be added
acc_speed_all_years = percent_all_years.*acc79_18;

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2020년 12월 3일

답변:

2020년 12월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by