Docsity

Aplicación de la distribución binomial y poisson: cálculo de probabilidades - Prof. Roque , Ejercicios de Programación Java

Vista previa parcial del texto

¡Descarga Aplicación de la distribución binomial y poisson: cálculo de probabilidades - Prof. Roque y más Ejercicios en PDF de Programación Java solo en Docsity!

1. REVISION DEL ANALISIS

2. DISEÑO EN INGENIERIA

BASE DEDATOS

Entidades – Atributos “ Distribución Binomial”:

Primeramente e realizado la interaz

BINOMIAL.fig

Hacemos la programación de los botones

function varargout = BINOMIAL(varargin) % BINOMIAL MATLAB code for BINOMIAL.fig % BINOMIAL, by itself, creates a new BINOMIAL or raises the existing % singleton. % % H = BINOMIAL returns the handle to a new BINOMIAL or the handle to % the existing singleton. % % BINOMIAL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in BINOMIAL.M with the given input arguments. % % BINOMIAL('Property','Value',...) creates a new BINOMIAL or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before BINOMIAL_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to BINOMIAL_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help BINOMIAL % Last Modified by GUIDE v2.5 29-Jan-2021 12:06: % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @BINOMIAL_OpeningFcn, ... 'gui_OutputFcn', @BINOMIAL_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before BINOMIAL is made visible. function BINOMIAL_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure

% str2double(get(hObject,'String')) returns contents of edit as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) x=strdouble(get(handles.edit1,'string')); n=strdouble(get(handles.edit2,'string')); p=strdouble(get(handles.edit3,'string')); B=binopdf(x,n,p); set(handles.edit4,'string',num2str(B)); BINOMIAL.m

APLICACIÓN DE LA DISTRIBUCION BINOMIAL

Ester quiere saber la probabilidad de venta de de su producto del mes de

enero.- su empresa mediante un sondeo estadístico Sabe que la

probabilidad de venta de piezas mecánicas es del 75% si la empresa saca

ala venta 140 piezas calcular la probabilidad de que:

a) Se vendan exactamente 100 piezas

b) Se vvendan mas de 125 piezas

PROCEDIMIENTO

Primerode finimos las variables donde n=140 , p=0,75 por tanto q =0.25 ,

pues p+q = 1 usamos matlab para los cálculos

a) Que sevenda exactamente100 piezas

pf1=binopdf(100,140, 0.75)

pf1 =0.

Primeramente e realizado la interfaz ya que por este método es mas

rapido la programación

poisoon.fig

Al ejecutar o darle en run aparece el cuadro con la

intrefazlista para ingresar los datos del problema

Seguido la programación en cada uno de los botones

function varargout = poisoon(varargin) % POISOON MATLAB code for poisoon.fig % POISOON, by itself, creates a new POISOON or raises the existing % singleton. % % H = POISOON returns the handle to a new POISOON or the handle to % the existing singleton. % % POISOON('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in POISOON.M with the given input arguments. % % POISOON('Property','Value',...) creates a new POISOON or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before poisoon_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to poisoon_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help poisoon % Last Modified by GUIDE v2.5 29-Jan-2021 08:02: % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @poisoon_OpeningFcn, ... 'gui_OutputFcn', @poisoon_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before poisoon is made visible. function poisoon_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn.

% str2double(get(hObject,'String')) returns contents of edit as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit3 as text % str2double(get(hObject,'String')) returns contents of edit as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) n=str2double(get(handles.edit1,'string')); p=str2double(get(handles.edit2,'string')); x=str2double(get(handles.edit3,'string')); B=poisspdf(x,(np)); set(handles.edit4,'string',num2str(B)); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) nn=str2double(get(handles.edit1,'string')); pp=str2double(get(handles.edit2,'string')); xx=str2double(get(handles.edit3,'string')); A=poisspdf(xx,(nnpp)); set(handles.edit4,'string',num2str(A)); % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) nnn=str2double(get(handles.edit1,'string')); ppp=str2double(get(handles.edit2,'string')); xxx=str2double(get(handles.edit3,'string')); AA=1-(poisspdf(x,(n*p))); set(handles.edit4,'string',num2str(AA)); poisoon.m

Ejerccio

APLICACIÓN DE LA DISTRIBUCION POISOON La probabilidad de que un consumidor compre un vehiculo de unaempresa TOYOTA es de una en diez mil a)cual es la probabilidad de qe exactamente 5 perosona compren un vehiculo en nuestra empresa de una población de 2000? b)cual es la probabilidad de que compren menos de 5 personas en la misma población? PROCEDIMIENTO para resolver este ejercicio en Matlab realizamos el siguiente proceso:

 - La probabilidad de que compren vehículos menos de - personas es de 98,34% de toda una población de 
  • la probabilidad mayor vendría a ser el complemento de 0.
  • por lo qe saldría 0.